I want to compare every element of each member of the list with every element of each member of another list.
A = B = list(1, 2, c(1,2))
Expected outcome is follows:
[,1] [,2] [,3]
[1,] TRUE FALSE TRUE
[2,] FALSE TRUE TRUE
[3,] TRUE TRUE TRUE
I can solve similar task for the data.frame:
df = data.frame(A = c(1, 2, "1,2"), B = c(1, 2, "1,2"))
sapply(df$A, grepl, df$B)
which gives:
[,1] [,2] [,3]
[1,] TRUE FALSE FALSE
[2,] FALSE TRUE FALSE
[3,] TRUE TRUE TRUE
But that is not exactly the solution I'm looking for.
Any help is much appreciated!