[R] What is wrong with this code?

Cable, Samuel B Civ USAF AFMC AFRL/RVBXI Samuel.Cable at hanscom.af.mil
Wed Jun 30 23:56:36 CEST 2010


> Okay, here is a reproducible example of a possible solution (actually
> it
> probably does not do what you want but it's a start for discussion.
> Note it is actual code and data which is what is needed.
> =======================================================
> str1 <- "abc"
> str2 <- "abcd"
> str3 <- "efgh"
> 
> grep(str1, str2)
> grep(str1,str3)
> =======================================================

Thanks for everybody's help on this and thanks for your patience with my
original mistake.

FWIW, grep doesn't quite do it because if I put it into an "if" test

if (grep(str1,str3) somethingsomething ) { ... }

and str3 does not contain str1, then R gets upset, won't even evaluate
the "if", and returns an error.

I'll take a look at grepl.  Turns out I don't have it because I am
currently running rev. 2.8.1-1.  Oh well.

Thanks again.



More information about the R-help mailing list