My data look like this
Q3A1<-c(0,1,0,1,1,1,0,1,0,1)
Q3A2<-c(0,1,1,1,0,1,0,0,0,1)
Q3A3<-c(1,1,0,1,0,1,0,0,0,1)
And I would like to create a new variable Q3L were it is coded as 1 when Q1A1, Q1A2 and Q1A3 are all equal to 1
I tried this
dataQ$Q3L <- ifelse(dataQ$Q3A1==1|dataQ$Q3A2==1|dataQ$Q3A3==1, 1, 0 )
but It seemslike it is recoding as 1 if at least one of the three equal 1, but I need the tree of them to be equal to 1
I tried this as well
library(dplyr)
dataQ %>%
mutate(Q3L = case_when(Q3A1 == 1 & Q3A2 == 1 & Q3A3 == 1 ~ 1,))
not a success neither