# RE: [R] Intersection of more than two groups in one function?

From: Berton Gunter <gunter.berton_at_gene.com>
Date: Fri 06 May 2005 - 07:05:29 EST

No, I know of no "canned" way to do it, as it's based on match(), which is for two vectors only.

A brute force loop to do it is simple, as I suspect you realize. Perhaps a faster way is to use tabulate() to find values that appear n times (for n vectors). That is:

## assume your integer vectors are components of a list, mylist.

## warning: not tested
bigvec<-unlist(mylist)
sort(unique(bigvec))[tabulate(bigvec)==length(mylist)]

• Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA

"The business of the statistician is to catalyze the scientific learning process." - George E. P. Box

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Ken Termiso
> Sent: Thursday, May 05, 2005 1:15 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Intersection of more than two groups in one function?
>
> Hi all,
>
> As far as I can tell, the only canned way to do an intersect
> between two
> vectors of ints is the intersect(vec1, vec2) function -- is
> there another
> function I'm missing for intersecting more than two vectors??
>
> TIA,
> Ken
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help