Find specified search patterns (in any order, not necessarily joined) in another vector of strings.

needleInHaystack(findMe, findIn)

Arguments

findMe

What are you looking for? A character vector.

findIn

Where are you looking for it? A character vector.

Value

A matrix with 1 indicating presence and 0 indicating absence.

References

http://stackoverflow.com/q/22129542/1270695

Author

Ananda Mahto

Examples

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