I have a 20-student dataframe and I need to identify the students who attended Stage 43 for two years or more.
aluno <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
etapa_2012 <- c(42, 43, 44, 43, 42, 43, 44, 45, 42, 43, 44, 45, 42, 43, 44, 44, 42, 43, 44, 45)
etapa_2013 <- c(43, 44, 45, 43, 43, 44, 45, 45, 43, 43, 45, 45, 43, 44, 45, 44, 43, 44, 45, 45)
etapa_2014 <- c(44, 45, 45, 43, 44, 45, 45, 45, 44, 43, 45, 45, 44, 45, 45, 45, 44, 45, 45, 45)
etapa_2015 <- c(45, 45, 45, 44, 45, 45, 45, 44, 43, 45, 45, 45, 45, 45, 45, 44, 43, 45, 45, NA)
fluxo<-data.frame(aluno, etapa_2012, etapa_2013, etapa_2014, etapa_2015)
But I can only add a new column identifying the students who made step 43.
fluxo$dois_ou_mais <-ifelse(fluxo$etapa_2012==43|fluxo$etapa_2013==43|fluxo$etapa_2014==43|fluxo$etapa_2015==43, 1, 0)
fluxo
Iwouldliketogettotheresultwhereonlystudents4,9,10and17weremarkedincolumntwo_or_more,sincetheyhavestep43inmorethanoneyear,asshownbelow.