I'm trying to detect terms using grepl, and I'm getting too many false positives. I was hoping there might be a way to require two successful matches of any term off the list (I have manual coding for a segment of my data and am trying to get the automation to at least roughly correspond to this, but I have about 5 times as many positives as I did with manual coding). I didn't see grepl as taking any argument requiring more than one match to trigger TRUE. Is there any way of requiring two matches to trigger a TRUE finding? Or is there some other function I should be using?
GenericColumn <- cbind(grepl(Genericpattern, Statement$Statement.Text, ignore.case = TRUE))
EDIT:
Here is a more concrete example:
Examplepattern <- 'apple|orange'
ExampleColumn <- cbind(grepl(Examplepattern, Rexample$Statement.Text, ignore.case = TRUE))
As is now, all of these will trigger true with grepl. I would only like the items with two references to trigger true.
Example data:
Rexample <- structure(list(Statement.Text = structure(c(2L, 1L, 3L, 5L, 4L
), .Label = c("This apple is a test about an apple.", "This is a test about apples.",
"This orange is a test about apples.", "This orange is a test about oranges.",
"This orange is a test."), class = "factor")), .Names = "Statement.Text", row.names = c(NA,
5L), class = "data.frame")
Desired Output: TRUE, FALSE, TRUE, TRUE, FALSE