I am trying to filter a column which contains several keywords (in this example dog and cat) but I am having problems as only the first element is being used.
Here is a dplyr method:
library(stringi) library(dplyr) data = data_frame( id = c(1:7), type = c("dog1","dog2" ,"cat1","cat2","zebra1", "parrot5", "elephant15") ) data %>% filter(animals %>% paste(collapse = "|") %>% stri_detect_regex(type, . ) )