[R] is there a function like %in% for characters?
Terry Mu
muster at gmail.com
Sun Apr 3 06:00:43 CEST 2005
thx, that's perfect. I thought of grep(), it also can do this.
I wonder if there is a document or book that explains things
categorically so it's easy to look up a function.
On Apr 2, 2005 10:54 PM, Liaw, Andy <andy_liaw at merck.com> wrote:
> 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
> >
> >
> >
>
> ------------------------------------------------------------------------------
> Notice: This e-mail message, together with any attachment...{{dropped}}
More information about the R-help
mailing list