Re: [R] Test for list membership

2011-05-30 Thread Marcin Włodarczak
On 05/30/2011 04:14 PM, Uwe Ligges wrote: 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)

Re: [R] Test for list membership

2011-05-30 Thread Sarah Goslee
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,

Re: [R] Test for list membership

2011-05-30 Thread Uwe Ligges
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

Re: [R] Test for list membership

2011-05-30 Thread Henrique Dallazuanna
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 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 obv

[R] Test for list membership

2011-05-30 Thread Marcin Wlodarczak
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