Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有这两个列表,我想找出这两个列表中列元素的数量:
> xl [[1]] [1] 1 2 3 4 5 > yl [[1]] [1] 4 3 5 6 7
所以,在这个例子中,答案是 3。有什么建议吗?
使用intersect:
intersect
x1 = list(c(1, 2, 3, 4, 5)) y1 = list(c(4, 3, 5, 6, 7)) length(intersect(x1[[1]], y1[[1]])) # 3