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 <>
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
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
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
4 matches
Mail list logo