[R] How to union the elements in a list?
bcarvalh at jhsph.edu
Wed Oct 28 20:26:55 CET 2009
and possibly you want a unique() on that...
On Oct 28, 2009, at 5:15 PM, Jorge Ivan Velez wrote:
> Hi Peng,
> Here is a suggestion:
> unique(do.call(c, l))
> #  1 3 4 6 7
> Best regards,
> On Wed, Oct 28, 2009 at 3:07 PM, Peng Yu <> wrote:
>> Suppose that I have a list of vectors. I want to compute the union of
>> all the vectors in the list. I could use 'for' loop to do so. But I'm
>> wondering what would be a better solution that does not need a 'for'
>> l=list(a=c(1,3,4), b=c(1,3,6), c=c(1,3,7), ....)
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help