[英]How to calculate intersect of elements of a list in R
我有10個列表,分別為: Thre1
, Thre2
, Thre3
, ...
, Thre10
。
我的輸出還應該是一個列表,以使輸出的第i
個元素與我的輸入列表的第i
個元素相交,例如:
output[[1]] = Reduce(intersect,
list=(Thre1[[1]],Thre2[[1]],Thre3[[1]],...,Thre10[[1]])
如何編寫代碼以防止Threi[[j]]
重復鍵入Threi[[j]]
?
假設所有列表的長度相同:
lapply(1:length(Thre1), function(i)
Reduce(intersect, list(Thre1[[i]], ..., Thre10[[i]])))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.