I don't think this exact question has been asked - lots of stuff on subsetting based on one value (i.e., x[grepl("some string", x[["column1"]]),]), but not multiple values/strings.
Here is an example of my data:
#create sample data frame
data = data.frame(id = c(1,2,3,4), phrase = c("dog, frog, cat, moose", "horse, bunny, mouse", "armadillo, cat, bird,", "monkey, chimp, cow"))
#convert the `phrase` column to character string (the dataset I'm working on requires this)
data$phrase = data$phrase
#list of strings to remove rows by
remove_if = c("dog", "cat")
This will give a dataset that looks like:
id phrase
1 1 dog, frog, cat, moose
2 2 horse, bunny, mouse
3 3 armadillo, cat, bird,
4 4 monkey, chimp, cow
I want to remove row 1 and row 3 (because row 1 contains "dog" and row 3 contains "cat"), but keep row 2 and row 4.
id phrase
1 2 horse, bunny, mouse
2 4 monkey, chimp, cow
In other words, I want to subset data so that it is only (the headers and) row 2 and row 4 (because they contain neither "dog" nor "cat").
Thanks!