Skip to content
Back to formatted view

Raw Message

Message-ID: <BANLkTikw1T4weWRvzKy-8v_14E_8ufPaeg@mail.gmail.com>
Date: 2011-05-30T14:14:43Z
From: Henrique Dallazuanna
Subject: Test for list membership
In-Reply-To: <16162_1306762575_ZZh0s2cgr0hga.00_4DE39D58.30303@uni-bielefeld.de>

Try this:

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

On Mon, May 30, 2011 at 10:36 AM, Marcin Wlodarczak
<mwlodarczak at 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
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paran?-Brasil
25? 25' 40" S 49? 16' 22" O