[R] intersect more than two sets

Weiwei Shi helprhelp at gmail.com
Tue Apr 24 21:43:03 CEST 2007


I had a similar solution by using frequency but having more codes :(

I also like the "recursive" idea : I initially tried to use rapply,
however, which can only take one-arg function.

thanks, everyone.

-w

On 4/24/07, hadley wickham <h.wickham at gmail.com> wrote:
> On 4/24/07, Tony Plate <tplate at acm.org> wrote:
> > I don't think there's that sort of "apply-reduce" function in R, but for
> > this problem, the last line below happens to be a "one-liner":
>
> Only if you have character data though:
>
> > x <- lapply(1:10, function(i) sample(20, 15))
> > names(which(table(unlist(x))==10))
> [1] "14"
>
> (not that it's hard to turn that back into a number)
>
> Hadley
>


-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III



More information about the R-help mailing list