Comparison Operator
OK, regexpr gets me what I needed, thanks to all.. One more thing, say I have a Table like: 0 RAW1 RAW2 RAW3 AVE1 AVE2 AVE3 1 1 2 5 2.3 1.2 4.5 2 0 3 6 1.7 2.2 3.5 3 3 1 6 0.1 3.9 1.6 and I want to create a sub table that only has the RAW columns. Problem is I won't know what the column names will be, only that they either contain "RAW" or "AVE" and they may not be grouped together. Mike -----Original Message----- From: Don MacQueen [mailto:macq at llnl.gov] Sent: Friday, May 30, 2003 8:48 AM To: Dirk Eddelbuettel; mhoward Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Comparison Operator grep() by itself isn't quite right for this job:
a<-"Is a Fish" b<-"aFish" if (grep(b,a)) c<-TRUE
Error in if (grep(b, a)) c <- TRUE : argument is of length zero -Don
At 6:24 PM -0500 5/29/03, Dirk Eddelbuettel wrote:
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.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
-------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA