I would like to create a new column that counts the number of "yes" occurrences across a select number of variables (X1 - X3). Here is an example of my dataframe:
df <- data.frame(name = paste0("name", 1:6),
X1 = c("yes","no","yes","yes","yes","maybe"),
X2 = c("yes","yes","yes","maybe","yes","maybe"),
X3 = c("no","yes","yes","maybe","yes","yes"))
I want my new column to look like this:
count_yes = c(2,2,3,1,3,1)
df2 <- cbind(df,count_yes)
Thank you!!