Hi everyone!
I'm having a problem similar to this one, but in my case, I don't want to replace the keywords naming every one of them. I have a larger dataset to work with and I would like to replace the words using the data frame column (let's assume worng_words and new_words are columns of a data frame)
An illustrative example:
text <- c("just writing an illustrative text for example,",
"but it has some different text in each sentence,",
"so I am just gonna replicate it in here.")
wrong_words <- c("illustrative text", "it in here", "for example")
new_words <- c("illustrative_text", "it_in_here", "for_example")
Now, I want to replace all the wrong_words for the new_words, but without naming them, just pulling them from data frame. Kind of:
str_replace_all(text, wrong_words, new_words)
or
gsub(text, wrong_words, new_words)
I know the functions above won't work that way, but it illustrates what I intend to.
Thanks for the help!