In R, let q
be a list with 100
components. Each component is a character vector:
i <-3
q[[i]]
[1] "A" "B" "C"
i <- 8
q[[i]]
[1] "B" "A" "D" "F"
and so on. I would like to intersect the components q[[i]]
, for all i
. As output I just need those characters which lie in the multiple intersection. I only know the function
intersect()
which works with 2 inputs and I don't really know Reduce
. Is there any smart-quick way to do this?
I thank you very much!
Just try this .
Reduce(intersect,q)
And If you want to show intermediate result:
Reduce(intersect,q,intermediate=TRUE)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.