This is pretty simple to do but this could potentially be a nice helper function. When mapping over elements of a vector, the attributes are lost before the function is applied:
library(purrr)
library(stringr)
keywords = stringr::coll(c("FOO", "BAR", "BAZ"), ignore_case = TRUE)
words = c("fuzz", "foo", "boat", "baz")
# stringr_pattern class is lost before str_detect is applied
map_lgl(keywords, function(x) any(stringr::str_detect(words, x)))
#> FALSE FALSE FALSE
It might be nice to have a helper function that applies the attributes of the input to each element, e.g.
This is pretty simple to do but this could potentially be a nice helper function. When mapping over elements of a vector, the attributes are lost before the function is applied:
It might be nice to have a helper function that applies the attributes of the input to each element, e.g.