[R] how to test if a vector contain a value?

Marius 't Hart M.t.Hart at ai.rug.nl
Mon Aug 16 15:15:26 CEST 2010


 > mylist = c(1,2,3)
 > if (any(mylist == 3)) { print(3) }
[1] 3
 >


On 08/16/2010 03:06 PM, Hyunchul Kim wrote:
> Hi all,
>
> How to convert following simple python script to R
>
>
> if x in a_list:
>      print x
>
> OR
>
> simply, how to test if a vector contain a value?
>
>
> Thank you in advance,
>
> Hyunchul
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list