R remove multiple text strings in data frame
问题 New to R. I am looking to remove certain words from a data frame. Since there are multiple words, I would like to define this list of words as a string, and use gsub to remove. Then convert back to a dataframe and maintain same structure. wordstoremove <- c("ai", "computing", "ulitzer", "ibm", "privacy", "cognitive") a id text time username 1 "ai and x" 10 "me" 2 "and computing" 5 "you" 3 "nothing" 15 "everyone" 4 "ibm privacy" 0 "know" I was thinking something like: a2 <- apply(a, 1, gsub