Skip to content
Back to formatted view

Raw Message

Message-ID: <AANLkTim2tCKr4QR2-U=6Hz8GE2SEg-=dO+UiPm8F3PZE@mail.gmail.com>
Date: 2010-12-13T14:48:30Z
From: C.H.
Subject: check for item in vector

Dear R users,

Suppose I have an vector like this:

animal <- c("Tiger","Panda")

I would like to know is there any function that check for the
existence of certain item in a vector.

e.g.

> func("Tiger",animal) # check for the existence of "Tiger"
TRUE
> func("Acacia",animal)  #Acacia is not an item of the animal vector
FALSE

I know that it can be done by for loop. But I would like to know is
there any built-in function for that.

Thank you very much.

CH

-- 
CH Chan