Let's say I have these two lists, and I want to figure out the number of column elements among these two lists:
> xl
[[1]]
[1] 1 2 3 4 5
> yl
[[1]]
[1] 4 3 5 6 7
So, in this example, the answer would be 3. Any suggestions?
Let's say I have these two lists, and I want to figure out the number of column elements among these two lists:
> xl
[[1]]
[1] 1 2 3 4 5
> yl
[[1]]
[1] 4 3 5 6 7
So, in this example, the answer would be 3. Any suggestions?
Use intersect
:
x1 = list(c(1, 2, 3, 4, 5))
y1 = list(c(4, 3, 5, 6, 7))
length(intersect(x1[[1]], y1[[1]]))
# 3