[R] Function to check if a vector contains a given value?

Henrique Dallazuanna wwwhsd at gmail.com
Wed Sep 23 19:07:57 CEST 2009


You can try this also:

is.element(2, x)

On Wed, Sep 23, 2009 at 12:37 PM, Dimitri Liakhovitski <ld7631 at gmail.com> wrote:
> Dear R'rs,
>
> is there a function that checks if a given vector contains a certain value.
> E.g., x<-c(1,2,3,4).
> How can I get a TRUE or FALSE for whether x contains a 2?
>
> --
> Dimitri Liakhovitski
> Ninah.com
> Dimitri.Liakhovitski at ninah.com
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list