我有兴趣交叉多个标识符列表,制作一个包含列表对('rk'与't')之间重叠数量的表。我有一个模糊的想法,即 sapply 是要走的路,但在搜索和阅读教程后我仍然卡住了。
rk1 <- list("YH_sensitive_933","CS_sensitive_1294","YH_sensitive_944","JB_persistent_1224","CS_sensitive_1299","YY_sensitive_922", "YH_sensitive_952","YA_sensitive_949")
rk2 <- list("YH_sensitive_944","JB_persistent_1224","CS_sensitive_1299","YY_sensitive_922", "YH_sensitive_952","YA_sensitive_949")
t1 <- list("YH_sensitive_933","CS_sensitive_1294","YH_sensitive_944")
t2 <- list("YH_sensitive_944","JB_persistent_1224")
t3 <- list("CS_sensitive_1299","YY_sensitive_922","YH_sensitive_944")
t4 <- list("YH_sensitive_952","YA_sensitive_949")
编辑:我认为最好将两个列表列表分组并按照建议尝试 sapply/mapply
F <- list(t1,t2,t3,t4)
G <- list(rk1,rk2)
> sapply(mapply(intersect,F,G), length)
[1] 3 2 3 2
但我是 R 初学者,非常感谢有关循环和使用应用函数的一些指导。但我只看到 rk1 的交叉点(但没有看到 rk2,应该是 1 2 3 2)