Really simple problem but I can't see this exact problem anywhere in Stackoverflow (and I can't work it out myself!). I want to return TRUE if a character string is present in any row of a dataframe (FALSE if not!). EG:
col1 <- c("no","no","no","no","pair")
col2 <- c("no","no","pair","no","no")
col3 <- c("chicks","no","pair","no","no")
df<- cbind.data.frame(col1,col2,col3)
df
col1 col2 col3
1 no no chicks
2 no no no
3 no pair pair
4 no no no
5 pair no no
#### I want col4 to be TRUE FALSE FALSE FALSE FALSE - return only rows with chicks
# I tried like col4<-lapply("chicks", grepl, x = df) but this runs on each column not each row
####I want col5 to be TRUE FALSE TRUE FALSE TRUE - any row with pair or chicks
# eg col5<-lapply("chicks"|"pair", grepl, x = df)