Re: [R] Test for list membership

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Mon, 30 May 2011 16:14:49 +0200

On 30.05.2011 15:36, Marcin Wlodarczak wrote:
>
> Hi,
>
> I need some help with this one: how do I check whether a vector is
> already present in a list of vectors.
>
> I have seen %in% recommended in a similar case but that obviously does
> not work here.
>
> c(1,2,3) %in% list(c(1,2,3), c(4,5,6))

You said it yourself, almost:

list(c(1,2,3)) %in% list(c(1,2,3), c(4,5,6))

Uwe Ligges

> returns
>
> [1] FALSE FALSE FALSE
>
> which makes sense since 1, 2 or 3 are not elements of that list. I don't
> really know how to move from there though.
>
> Best wishes,
> Marcin
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 30 May 2011 - 14:20:59 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 30 May 2011 - 18:50:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive