Re: [R] Using ifelse and grep

2010-04-03 Thread Sam Albers
Fantastic. Solved. Thanks! On Sat, Apr 3, 2010 at 9:59 AM, Gabor Grothendieck wrote: > # 1 > grep returns an index, not the value unless you use grep(..., value = > TRUE). > > Easier might be: > > # 2 > Sample2 <- substr(Sample, 1, 2) > ifelse(Sample2 == "BU", "up", ifelse(Sample2 == "BM", "mid

Re: [R] Using ifelse and grep

2010-04-03 Thread Gabor Grothendieck
# 1 grep returns an index, not the value unless you use grep(..., value = TRUE). Easier might be: # 2 Sample2 <- substr(Sample, 1, 2) ifelse(Sample2 == "BU", "up", ifelse(Sample2 == "BM", "mid", "down")) or #3 the following which matches the first 2 characters against the given list names and

Re: [R] Using ifelse and grep

2010-04-03 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Sam Albers > Sent: Saturday, April 03, 2010 9:18 AM > To: r-help@r-project.org > Subject: [R] Using ifelse and grep > > Good Morning, > > I am trying to create a new column of c