我已经附上了表的图像,我想根据下面的搜索criteria.Title列包含文本来过滤列‘标题’。
word=c('COVID','coronavirus disease 19','SARS-CoV-2','2019-nCoV','nCoV','coronavirus','wuhan pneumonia','Wuhan')
搜索一个我知道我可以使用的词
merged[grep("COVID",merged$Title),"Title"]或
sapply(words, grepl, merged$Title) returns TRUE and FALSE. How to select the rows for which sapply is true.
发布于 2020-04-10 05:21:22
我们可以使用lapply并将其合并到一个带有|的单个逻辑标题中,以便对“vector”的行进行子集设置,即,当“vector”列中存在任何“Reduce”时,我们选择“vector”的行
merged[Reduce(`|`, lapply(words, grepl, merged$Title)),]另一种选择是将其paste为单个字符串,并使用|作为分隔符,其作用类似于OR
pat <- paste0("\\b(", paste(words, collapse="|"), ")\\b")
merged[grepl(pat, merged$Title),]https://stackoverflow.com/questions/61130384
复制相似问题