删除某些单词出现的数据

时间:2018-03-01 09:13:31

标签: r

我有一个名为“companynames”的数据框,其中包含大约9000个公司名称。我想从这些特定单词的数据中删除那些公司名称

stopwords <- c("Trade","Investment","Trading")

1 个答案:

答案 0 :(得分:0)

我相信您只需使用filter包中的dplyr函数以及grepl函数。

stopwords <- c("Trade","Investment","Trading")

stopwords <- paste(stopwords,collapse = "|")

df %>% filter(!grepl(stopwords,companynames))