I'd like to ask a question inspired by this question asked years ago here in stack overflow
given the data frame: input_df
num_col_1 num_col_2 text_col_1 text_col_2
1 1 4 yes yes
2 2 5 no yes
3 3 6 no <NA>
this chunk of code
library(dplyr)
df %>%
mutate(sum_yes = rowSums(.[c("text_col_1", "text_col_2")] == "yes"))
will produce this new dataframe
> output_df
num_col_1 num_col_2 text_col_1 text_col_2 sum_yes
1 1 4 yes yes 2
2 2 5 no yes 1
3 3 6 no <NA> 0
The question is, how do you do the same with modern dplyr verbs across and c_across?
thank you.