I am facing problem with using grep/grepl function in R. When I run grepl for multiple strings I do not know how to produce required result.
Text1 <- c("instance", "percentage", "n",
"instance percentage", "percentage instance")
ID <- c(1,2,3,4,5)
A <- c("A","B","C","D","E")
df <- data.frame(ID, Text1, A)
I want to find the string instance or percentage (or both and add another column "Result" and give 1 each time is found.
Results would look like this:
ID Text1 A Result
1 instance A 1
2 percentage B 1
3 n C
4 instance percentage D 1
5 percentage instance E 1