You almost solved your own problem with that last statement. Instead
of comparing apples and oranges, you need to compare oranges and
oranges:

> list(c(1,2,3)) %in% list(c(1,2,3), c(4,5,6))
[1] TRUE
> list(c(1,2,3)) %in% list(c(1,2,9), c(4,5,6))
[1] FALSE

Sarah


On Mon, May 30, 2011 at 9:36 AM, Marcin Wlodarczak
<mwlodarc...@uni-bielefeld.de> 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))
>
> 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
>
-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
R-help@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.

Reply via email to