Using this example answer
I try to use it to keep words into a whole column.
I use this:
df <- data.frame(text = c ("Hi this is an example", "Hi this is an example", "Hi this is an example", "Hi this is an example"))
words <- c("this", "is", "an", "example")
paste(intersect(strsplit(df$text, "\\s")[[1]], words), collapse=" ")
But I receive this error:
Error in strsplit(df$text, "\\s") : non-character argument
What can I do?