[R] list matching

Adrian Dusa dusa.adrian at gmail.com
Sat Oct 6 21:49:08 CEST 2007


Dear list,

Given a list of elements like:
aa <- list(one=c("o", "n", "e"),
               tea=c("t", "e", "a"),
               thre=c("t", "h", "r", "e"))

Is there a function that returns the intersection between all?
Both match() and intersect() only deal with two arguments, but sometimes I 
have more.

Here, it should return "e" (or NA if none of the letters are common).

I have a solution to apply %in% multiple times (here two times, first between 
the first two and then between the result and the third) but... perhaps there 
is a better and quicker way.

Thanks in advance,
Adrian

--
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
          +40 21 3120210 / int.101



More information about the R-help mailing list