[R] Problem with modifying a data frame
SNN
s.nancy1 at yahoo.com
Tue Aug 11 20:05:21 CEST 2009
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 6 b
4 6 b
5 8 c
if (data$x==6){
data$x<-66
}
Warning message:
In if (data$x == 6) { :
the condition has length > 1 and only the first element will be used
>
I woul dlike to change the 6 in column x into 66
why the above did not work?
Thanks
--
View this message in context: http://www.nabble.com/Problem-with-modifying-a-data-frame-tp24922814p24922814.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list