Re: [R] selecting elements in vector

2011-01-14 Thread Henrique Dallazuanna
Try this: !list %in% c("aa", "bb") On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote: > Hi everybody, > > I have the following problem. I have a vector containing character > elements, > such as: > > list = c("aa","bb","cc","dd","ee") > > I want to create an index which identifies the element

Re: [R] selecting elements in vector

2011-01-14 Thread A M Lavezzi
it works! thank you so much Mario On Fri, Jan 14, 2011 at 1:29 PM, Henrique Dallazuanna wrote: > Try this: > > !list %in% c("aa", "bb") > > On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote: > >> Hi everybody, >> >> I have the following problem. I have a vector containing character >> element

Re: [R] selecting elements in vector

2011-01-14 Thread Henrique Dallazuanna
Try this: !list %in% c("aa", "bb") On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote: > Hi everybody, > > I have the following problem. I have a vector containing character > elements, > such as: > > list = c("aa","bb","cc","dd","ee") > > I want to create an index which identifies the element

[R] selecting elements in vector

2011-01-14 Thread A M Lavezzi
Hi everybody, I have the following problem. I have a vector containing character elements, such as: list = c("aa","bb","cc","dd","ee") I want to create an index which identifies the elements that are different from, e.g. "aa" and "bb". When I do the following: jj = list!="aa" & list!="bb" > j

Re: [R] Selecting elements in vector

2008-03-14 Thread Rainer M Krug
Thanks - that is exactly what I was looking for Rainer On Fri, Mar 14, 2008 at 1:10 PM, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: > Try this: > > x[x %in% y] > > > > On 14/03/2008, Rainer M Krug <[EMAIL PROTECTED]> wrote: > > Hi > > > > Consider the following code > > > > > x <- re

Re: [R] Selecting elements in vector

2008-03-14 Thread Gabor Csardi
Use %in%: x [ x %in% y ] G. On Fri, Mar 14, 2008 at 12:37:45PM +0200, Rainer M Krug wrote: > Hi > > Consider the following code > > > x <- rep(1:13, 13) > > > y <- 1:3 > > I want to select all elements in x which are equal to 1, 2 or 3. > > I know that I could use > > > sel <- x==y[1] | x=

Re: [R] Selecting elements in vector

2008-03-14 Thread Henrique Dallazuanna
Try this: x[x %in% y] On 14/03/2008, Rainer M Krug <[EMAIL PROTECTED]> wrote: > Hi > > Consider the following code > > > x <- rep(1:13, 13) > > > y <- 1:3 > > I want to select all elements in x which are equal to 1, 2 or 3. > > I know that I could use > > > sel <- x==y[1] | x==y[2] | x==y[3

[R] Selecting elements in vector

2008-03-14 Thread Rainer M Krug
Hi Consider the following code > x <- rep(1:13, 13) > y <- 1:3 I want to select all elements in x which are equal to 1, 2 or 3. I know that I could use > sel <- x==y[1] | x==y[2] | x==y[3] > x[sel] to obtain the values, but in my analysis, the y-vector is thousands of elements long. Is ther