Here are two ways using binary logic. The second is an application of de Morgan's laws.
A <- c(1:3)
B <- c("Sweet", "Home", "Sweet Home")
df <- data.frame(A,B)
i <- grepl("sweet", df$B, ignore.case = TRUE)
j <- grepl("home", df$B, ignore.case = TRUE)
df[!(i & !j), ]
#> A B
#> 2 2 Home
#> 3 3 Sweet Home
df[!i | j, ]
#> A B
#> 2 2 Home
#> 3 3 Sweet Home
Created on 2022-09-13 with reprex v2.0.2
Edit
If you have one word to drop unless a list of words is present, the function below might be what you want. The words vector must have the unwanted word first, followed by the other, wanted words.
# X is the input data.frame
# col is the column to search for
specialfilter <- function(X, col, words) {
l <- lapply(words, \(w) grepl(w, X[[col]], ignore.case = TRUE))
l[[1]] <- !l[[1]]
i <- Reduce(`|`, l)
X[i, ]
}
specialfilter(df, "B", c("sweet", "home"))
#> A B
#> 2 2 Home
#> 3 3 Sweet Home
Created on 2022-09-13 with reprex v2.0.2