[R] How to update a column in a dataframe, more simply...

Mark Na mtb954 at gmail.com
Sat Sep 27 00:35:11 CEST 2008


Hello,

I would like to be able to update an existing column in a dataframe, 
like this...

data$score[data$type=="1" & data$year=="2001"]<-data$score * 0.111
data$score[data$type=="1" & data$year=="2002"]<-data$score * 0.222
data$score[data$type=="1" & data$year=="2003"]<-data$score * 0.333

...but, if possible, using simpler code. I've got several dozen lines of 
code like this (type 2, type3, etc. for the same years) so it would be 
great if I could reduce each set of three lines of code to one line

Any help much appreciated, thanks!

Mark



More information about the R-help mailing list