I have quite a big dataset which has 2 text variables A and B. length(A) <= length(B). B can be either variable A with some extra characters (without order) or can be totally different from A. So i need to to create new variable within my data table under this condition:
If B contains A then C = TRUE. I believe partial string matching is more suitable for me here than normal string comparison.
My dataframe example:
Home Pick
Barc Barcelona 0
F Munch FC munchen
Lakers Portland
I need to add new variable Side in this way:
Home Pick Side
Barc Barcelona 0 True
F Munch FC munchen True
Lakers Portland False
i am trying to solve with this:
data_n$Side <- stringMatch(data_n$Home, data_n$Pick, normalize = "YES")
but it gives all negative results.
Hoverer
stringMatch('barcel', 'Barcelona 0', normalize='YES')
gives needed answer. Any hints where i make mistake?
agrepis a useful base solution for partial matching