Consider this character
mystring <- "this, this and this, and this, and this."
I want to split on , or and but I want to get rid of the empty strings. I am puzzled by the fact that my solution below does not work
splitting works OK
> str_split(mystring, regex(',|and'))
[[1]]
[1] "this" " this " " this" " " " this" " " " this."
filtering does not work
> str_split(mystring, regex(',|and')) %>% purrr::keep(., function(x) x!= '')
Error: Predicate functions must return a single `TRUE` or `FALSE`, not a logical vector of length 7
Run `rlang::last_error()` to see where the error occurred.
What is the issue here? Thanks!