Find specified search patterns (in any order, not necessarily joined) in another vector of strings.
needleInHaystack(findMe, findIn)
findMe | What are you looking for? A character vector. |
---|---|
findIn | Where are you looking for it? A character vector. |
A matrix with 1 indicating presence and 0 indicating absence.
http://stackoverflow.com/q/22129542/1270695
Ananda Mahto
x <- c("cat", "dog", "rat", "far", "f*n", "god", "g*dn") y <- c("ar", "n*", "a", "zo") needleInHaystack(y, x)#> ar n* a zo #> cat 0 0 1 0 #> dog 0 0 0 0 #> rat 1 0 1 0 #> far 1 0 1 0 #> f*n 0 1 0 0 #> god 0 0 0 0 #> g*dn 0 1 0 0