Skip to content
Prev 316359 / 398506 Next

Thank you your help and one more question.

HI,

I don't have Amelia package installed.


If you want to get the mean value, you could use either ?aggregate(),? or ?ddply() from library(plyr)

library(plyr)
imputNew<-do.call(rbind,imput1_2_3)
?res1<-ddply(imputNew,.(ID,CTIME),function(x) mean(x$WEIGHT))
?names(res1)[3]<-"WEIGHT"
?head(res1)
?# ?? ID CTIME?? WEIGHT
#1 HM001? 1223 24.90000
#2 HM001? 1224 25.20000
#3 HM001? 1225 25.50000
#4 HM001? 1226 25.41933
#5 HM001? 1227 25.70000
#6 HM001? 1228 27.10000


#or
res2<-aggregate(.~ID+CTIME,data=imputNew,mean)
#or
res3<-? do.call(rbind,lapply(split(imputNew,imputNew$CTIME),function(x) {x$WEIGHT<-mean(x[,3]);head(x,1)}))
row.names(res3)<-1:nrow(res3)
identical(res1,res2)
#[1] TRUE
?identical(res1,res3)
#[1] TRUE
A.K.
Message-ID: <1359429610.20889.YahooMailNeo@web142604.mail.bf1.yahoo.com>
In-Reply-To: <d8057f48638c7f190a62e509ed637@tweb21.nm.nhnsystem.com>