[R] is there a function like %in% for characters?

Liaw, Andy andy_liaw at merck.com
Sun Apr 3 05:54:35 CEST 2005


I suppose here's one way:

> hasChar <- function(x, y) { length(grep(x, y)) > 0 }
> hasChar("a", "abcd")
[1] TRUE
> hasChar("e", "abcd")
[1] FALSE

Andy

> From: Terry Mu
> 
> like:
> 
> "a" %in% "abcd"
> TRUE
> 
> Thanks.
> 
> ______________________________________________
> R-help at 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
> 
> 
>




More information about the R-help mailing list