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 not, is there a R way to code it in a couple of lines?
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"