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
Intersection of more than two groups in one function?
2 messages · Ken Termiso, Bert Gunter
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 at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Ken Termiso Sent: Thursday, May 05, 2005 1:15 PM To: r-help at 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 at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html