Message-ID: <CAC72A0B-EA67-48EB-BBA6-E8364158547F@auckland.ac.nz>
Date: 2008-09-09T02:11:42Z
From: Rolf Turner
Subject: isolate elements in vector that match one of many possible values
In-Reply-To: <31a7f73a0809081855x40ea173ia27d8b53270f3262@mail.gmail.com>
On 9/09/2008, at 1:55 PM, Andrew Barr wrote:
> Hi all,
>
> I want to get the index numbers of all elements of a vector which
> match any
> of a long series of possible values. Say x <- c(1,2,3,4) and I
> want to know
> which values are equal to 1, 2 or 4. I could do
>
> which(x == 1 | x==2 | x==4)
> [1] 1 2 4
>
> This gets really ugly though, when the list of values of interest
> is really
> long. Is there a nicer way to do this?
which(x%in%c(1,2,4))
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}