I am working on a text analysis project in R and want to search for certain words in my response data.
Essentially I am trying to write this:
df$word1 <- ifelse(grepl("word1", df$responses), 1, 0)
Where df$word1 is a new column in df, "word1" is the pattern to search for in the column of responses (df$responses).
This works fine for just one word, but I have ~250 patterns I want to individually search for, is there a way to do this without having to manually write code for each? I appreciate any help I can get!