I am having the following dataframe:
data <- data.frame(
text = c(
"PARACETAMOL/CODEINE",
"PSEUDOEPH/PARACET/CODEINE",
"PARACETAMOL/CODEINE/DOXYLAMINE",
"CODEINE & ASPIRIN",
"CODEINE/PARACETAMOL"
),
stringsAsFactors = F
)
And I just wanted to return the position of CODEINE with respect to each case:, i.e
text position
PARACETAMOL/CODEINE 2
PSEUDOEPH/PARACET/CODEINE 3
PARACETAMOL/CODEINE/DOXYLAMINE 2
CODEINE & ASPIRIN 1
CODEINE/PARACETAMOL 1
I prefer a DPLYR solution to run over hundreds of rows.
Any help would be greatly appreciated.