Hello,
I am looking for a way to essentially use vecsets::vintersect
with Reduce
so I can run it for all lists. It is vitally important that I should be able to have multiple items returned as in the example as although the numbers are unique the amount matters.
You will see with reduce(intersect)
it works in showing us the minimal intersect as where I would like the overall intersect between a_1, b_1, and c_1 (which should be 3,9,9). I essentially want to compare an arbitrary large size of collections and determine this "special" intersect. I am sure there might be a good existing solution hence asking about reduce. I essentially need the speed given I am going to be performing a lot of these sorts of comparisons.
Any help would be much appreciated!
library(vecsets)
#> Warning: package 'vecsets' was built under R version 4.0.5
a_1 <- c(1,3,3,5,7,9,9)
b_1 <- c(3,6,8,9,9)
c_1 <- c(2,3,3,4,5,7,9,3,9)
vecsets::vintersect(a_1,b_1, multiple = TRUE)
#> [1] 3 9 9
vecsets::vintersect(a_1,c_1, multiple = TRUE)
#> [1] 3 3 5 7 9 9
Reduce(intersect, list(a_1,b_1,c_1))
#> [1] 3 9
Created on 2022-02-22 by the reprex package (v2.0.0)