Re: [R] help with replacing factors

2009-05-24 Thread Andreas Christoffersen
Hi Mike and Gabor - thx for the help. It seams I have made a mistake in my original question. While Mike's solutions worked on the example data I provided, I now see my actual data is > is(df100_lang$gray) [1] "character" "vector" "data.frameRowLabels" and the solution do

Re: [R] help with replacing factors

2009-05-24 Thread Gabor Grothendieck
Try storing them as character strings rather than factors: black_gray <- data.frame(black, gray, stringsAsFactors = FALSE) Try this to view what you've got: str(black_gray) On Sun, May 24, 2009 at 7:15 AM, Andreas Christoffersen wrote: > Hi, > > In the example dataset below - how can I cahnge

Re: [R] help with replacing factors

2009-05-24 Thread Mike Lawrence
This should work: levels(black_gray$gray)[levels(black_gray$gray)=='gray20'] = 'blue' On Sun, May 24, 2009 at 8:15 AM, Andreas Christoffersen wrote: > Hi, > > In the example dataset below - how can I cahnge "gray20", to "blue" > > # data > black <- rep(c("black","red"),10) > gray <- rep(c("gray1

[R] help with replacing factors

2009-05-24 Thread Andreas Christoffersen
Hi, In the example dataset below - how can I cahnge "gray20", to "blue" # data black <- rep(c("black","red"),10) gray <- rep(c("gray10","gray20"),10) black_gray <- data.frame(black,gray) # none of this desperate things works # replace(black_gray$gray, gray=="gray20","red") # if(black_gray$gray==