I have a dataframe:
id <- c(1:5)
name <- c("blackdog","whitedog", "blackcat","whitecat","greyrabbit")
df <- data.frame(id,name)
df
I also have a list for selection:
select <- c("black","dog","grey")
So I want to return a dataframe containing: blackdog, blackcat,whitedog,greyrabbit
I have tried:
dfselect <-df[grep(select,df[,2]),]
dfselect
but this is only selecting the first element of the list.
I would be grateful for your help.