I'm trying to get all the "banana + word" ocurrences of a given object, but the str_extract returns only the first occurence. My code:
all_terms <- c("banana word2 word3 word4 banana split word2 word3 word4",
"x y z",
"banana ice cream")
banana_terms <- all_terms %>%
str_extract("banana.+") %>%
word(1,2)
banana_terms
Out: [1] "banana word2" NA "banana ice"
What I wanted:
Out: [1] "banana word2" "banana split", "banana ice"