[R] Function to check the presence of an Item in an array
Dimitris Rizopoulos
Dimitris.Rizopoulos at med.kuleuven.be
Fri Aug 1 10:52:52 CEST 2008
check ?"%in%", e.g.,
x <- c("foo", "bar", "bar2", "qux")
"foo" %in% x
"GUNDALA" %in% x
I hope it helps.
Best,
Dimitris
---
Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://perswww.kuleuven.be/dimitris_rizopoulos/
Quoting Gundala Viswanath <gundalav at gmail.com>:
> Hi all,
>
> Is there a way to do it?
> For example:
>
>> x
> "foo" "bar" "bar2" "qux"
>
> is there a function to return TRUE/FALSE
> given a test variable
>
>> func("foo")
> TRUE
>
>> func("GUNDALA")
> FALSE
>
> Is there such "func" in R?
>
> - Gundala Viswanath
> Jakarta - Indonesia
>
> ______________________________________________
> R-help at r-project.org 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.
>
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list