Re: [R] test if vector contains elements of another vector (disregarding the position)

2011-08-22 Thread Henrique Dallazuanna
Try this: i %in% j * 1 On Mon, Aug 22, 2011 at 12:51 PM, Martin Batholdy wrote: > Hi, > > > I have the following problem: > > > I have two vectors: > > i <- c('a','c','g','h','b','d','f','k','l','e','i') > > j <- c('a', 'b', 'c') > > > > now I would like to generate a vector with the length of i

Re: [R] test if vector contains elements of another vector (disregarding the position)

2011-08-22 Thread R. Michael Weylandt
%in% Here, i %in% j Hope this helps, Michael On Mon, Aug 22, 2011 at 11:51 AM, Martin Batholdy wrote: > Hi, > > > I have the following problem: > > > I have two vectors: > > i <- c('a','c','g','h','b','d','f','k','l','e','i') > > j <- c('a', 'b', 'c') > > > > now I would like to generate a ve

[R] test if vector contains elements of another vector (disregarding the position)

2011-08-22 Thread Martin Batholdy
Hi, I have the following problem: I have two vectors: i <- c('a','c','g','h','b','d','f','k','l','e','i') j <- c('a', 'b', 'c') now I would like to generate a vector with the length of i that has zeros where i[x] != any element of j and 1 where i[x] == any element of j. So for the examp