a <- c("ab","bc")
b <- c("ab cd","a bc","ab")
outer(b,a,str_detect)
[,1] [,2]
[1,] TRUE FALSE
[2,] FALSE TRUE
[3,] TRUE FALSE
> outer(a,b,str_detect)
[,1] [,2] [,3]
[1,] FALSE FALSE TRUE
[2,] FALSE FALSE FALSE
outer(a,b,grepl)
[,1] [,2] [,3]
[1,] TRUE FALSE TRUE
[2,] TRUE FALSE TRUE
outer(b,a,grepl)
[,1] [,2]
[1,] FALSE FALSE
[2,] FALSE FALSE
[3,] FALSE FALSE