我尝试使用库(“ stringr”),但仅有助于查找单个单词。疾病名称可以是两个或两个以上名称,例如:脑癌,骨髓性白血病等。 我们如何借助字典来映射疾病名称?
我正在使用以下代码。
library(stringr)
economic_tweets<-trumptweets[str_detect(trumptweets$text, economic_dictionary),]
head(economic_tweets$text)
在这里
economic_dictionary<-c("economy","unemployment","trade","tariffs")
if my data is in the following manner:
[1] this is black dog.
[2] this is white dog.
[3] Sheela has a black dog.
[4] Tom loves his dog.
and I create a dictionary with:
dictionary_test = c("black dog", "white dog")
我希望结果仅包含前三个数据行,因为它们包含字典中定义的术语。