Your solution helped me think of a non-tidy solution:
library(stringr)
df$all <- paste0(df$X1, df$X2, df$X3, df$X4, df$X5, pattern= "")
df$count_4 <- str_count(df$all, "4")
Thank you, FJCC
Your solution helped me think of a non-tidy solution:
library(stringr)
df$all <- paste0(df$X1, df$X2, df$X3, df$X4, df$X5, pattern= "")
df$count_4 <- str_count(df$all, "4")
Thank you, FJCC