Intersection of lists in R

后端 未结 2 1867
夕颜
夕颜 2021-02-13 03:09

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:22

    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"
    

提交回复
热议问题