[R] Comparison Operator

Dirk Eddelbuettel edd at debian.org
Fri May 30 01:24:56 CEST 2003


On Thu, May 29, 2003 at 05:11:24PM -0600, mhoward at micron.com wrote:
> Does R have a comparison operator similar to the Like function, for example:
> 
> a<-"Is a Fish"
> b<-"Fish"
> 
> if(b in a){c<-TRUE}

You probably want grep:

> a<-"Is a Fish"
> b<-"Fish"
> if (grep(b,a)) c<-TRUE
> c
[1] TRUE

Hth, Dirk 

-- 
Don't drink and derive. Alcohol and analysis don't mix.




More information about the R-help mailing list