根据关键字矢量过滤文本列

时间:2017-07-05 10:19:23

标签: r string dplyr stringi

以下是dput()信息

structure(list(Text = c("bandwidth issues. issues with vpn", 
"be more customer focussed reduce prices and offer same deas to existing customers that they use to attract new ones", 
"be more helpful and provide a better service.", "better customer service", 
"better customer service and products", "better customer service more transparency competency", 
"better customer service uk based. greater reliability and customer support", 
"better customer service. a more coherent ad that is better explained.", 
"better customer services", "better customer services and they could be truthful"
)), .Names = "Text", row.names = c(NA, -10L), class = c("tbl_df", 
"tbl", "data.frame"))

我希望根据filter中的关键字vector这些行。

这是我到目前为止所尝试过的,但不明白为什么它仍会带来另一个没有匹配的text

phrase = c("staff","agent","advisor","english","foreign","indian","gentleman","lady","man","woman","people","uk",
       "speak","supervisor","manager","spoke","spoken","non-uk","representative","he","she")

phrase_match <- str_c(phrase, collapse = "|")

brand_nps_filtered%>%
              filter(str_detect(Text, phrase_match))

正如您所看到的那样,be more customer focused reduce prices and offer same deas to existing customers that they use to attract new ones

带来了phrase没有关联的关键字

0 个答案:

没有答案