我处理的是如下[R排除关键字
Has no anorexia
She denies anorexia
Has anorexia
Positive for Anorexia
我的目标是排除有话像denies, denied, no
,只保留厌食的积极迹象句子句的句子。
最终的结果应该是
Has anorexia
Positive for Anorexia
我试着用grepl功能
negation <- c("no","denies","denied")
if (grepl(paste(negation,collapse="|"), Anorexia_sentences[j]) == TRUE){
Anorexia_sentences[j] <- NA
}
,这是行不通的这个选项,我认为没有在A字no
惹下会引起一些问题。任何建议如何解决这个问题,非常感谢。
你缺少'denied'之后的一个报价 – lawyeR
也许'否定<-c(“\\ bno \\ b”,...) –
您不需要循环,if或任何东西只要'denies = grepl (...,Anorexia_sentences); Anoreia_sentences [denies] = NA' – Gregor