Re: [R] Problem with modifying a data frame

2009-08-12 Thread Jorge Ivan Velez
Dear Nancy, Try also: x <- c(4,5,6,6,8) y <- c("a","b","b","b","c") mydata <- data.frame(x,y) mydata mydata$x <- with(mydata, ifelse(x == 6, 66, x)) mydata See ?ifelse for more details. BTW, be careful: "data" is an R reserved name :-) HTH, Jorge On Tue, Aug 11, 2009 at 2:05 PM, SNN <>

Re: [R] Problem with modifying a data frame

2009-08-12 Thread Henrique Dallazuanna
Try this: data$x[data$x == 6] <- 66 On Tue, Aug 11, 2009 at 3:05 PM, SNN wrote: > > Hi All, > > this could be a simple question but I am looking into modifying a data > frame > using a "condition" without the need to loop over that data, would that be > possible? > > I have tried the following

Re: [R] Problem with modifying a data frame

2009-08-11 Thread Leon Yee
Hi, this could be a simple question but I am looking into modifying a data frame using a "condition" without the need to loop over that data, would that be possible? I have tried the following x<-c(4,5,6,6,8) y<-c("a","b","b","b","c") data<-data.frame(x,y) data x y 1 4 a 2 5 b 3 6 b 4 6 b

[R] Problem with modifying a data frame

2009-08-11 Thread SNN
Hi All, this could be a simple question but I am looking into modifying a data frame using a "condition" without the need to loop over that data, would that be possible? I have tried the following > x<-c(4,5,6,6,8) > y<-c("a","b","b","b","c") > data<-data.frame(x,y) > data x y 1 4 a 2 5 b 3