[R] intersection on more than two sets

jim holtman jholtman at gmail.com
Thu Jun 3 10:20:41 CEST 2010


?Reduce

> x <- function(z) Reduce('union', z)
> x(list(1:3, 4:6))
[1] 1 2 3 4 5 6
> x(list(1:3, 4:6, 3:7))
[1] 1 2 3 4 5 6 7
> x <- function(z) Reduce('intersect', z)
> x(list(1:3, 4:6, 3:7))
integer(0)
> x(list(1:3, 2:6, 3:7))
[1] 3


On Thu, Jun 3, 2010 at 3:59 AM, amir <amir at ac.upc.edu> wrote:
> Hi,
>
> I want to do an intersection or union on more than two sets.
> Is there any command to do this?
>
> Regards,
> Amir
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list