Intersection of lists in R

后端 未结 2 1445
挽巷
挽巷 2021-02-13 03:08

Is there a function that receives a list x and returns a list y such that y[[i]] = intersect(x[[1]][[i]], x[[2]][[i]], ...) ?

If n

2条回答
  •  孤城傲影
    2021-02-13 03:42

    It seems the Reduce can be simply used as follows:

    > Reduce(intersect,  list(v1 = c("a","b","c","d"), 
    +                         v2 = c("a","b","e"), 
    +                         v3 = c("a","f","g"))) 
    [1] "a"
    

提交回复
热议问题