Re: [R] Check for presence of object in group of objects

From: Chuck Cleland <ccleland_at_optonline.net>
Date: Wed 31 Jan 2007 - 10:05:16 GMT

Christoph Heibl wrote:
> Dear List,
>
> must be simple, but i got stuck on this...
>
> Ive been trying around for some time, but I could not find a
> straigthforward way to do this:
> How can one ask if a certain object is element of a certain group of
> objects, e.g stored in a vector?
>
> x <- c("a", "b", "c")
> # is there a simple function which returns:
> is "a" part of x?
> TRUE
> is "d" part of x?
> FALSE
x <- c("a", "b", "c")

"a" %in% x
[1] TRUE "d" %in% x
[1] FALSE ?is.element

> Thanks a lot
> Christoph
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Jan 31 21:13:34 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 31 Jan 2007 - 10:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.