I'm curious to know if it is possible to do partial string matches using the %in% operator in R. I know that there are many ways to use stringr, etc. to find partial string matches, but my current code works easier using the %in% operator.
For instance, imagine this vector:
x <- c("Withdrawn", "withdrawn", "5-Withdrawn", "2-WITHDRAWN", "withdrawnn")
I want each of these to be TRUE because the string contains "Withdrawn", but only the first is TRUE:
x %in% c("Withdrawn")
[1] TRUE FALSE FALSE FALSE FALSE
I tried using regex to at least make it case insensitive, but that made everything false:
x %in% c("(?i)Withdrawn")
[1] FALSE FALSE FALSE FALSE FALSE
So, is it possible to yield TRUE on all of these using the %in% operator with maybe a wrapper? Because it's easy to use tolower() or toupper(), I'm not as concerned with the case sensitivity; however, it is important to me that the code would trigger "withdrawn", "withdrawnn", and "5-withdrawn".
EDIT: This question was marked as a duplicate of this question Case-insensitive search of a list in R; however, it is different because it is asking if partial string matches are possible using the %in% operator. The linked question does not use the %in% operator at all.