Skip to content
Prev 316358 / 398506 Next

Thank you your help and one more question.

HI,

How do you want to combine the results?
It looks like the 5 datasets are list elements.

If I take the first three list elements,
imput1_2_3<-list(imp1=structure(list(ID = c("HM001", "HM001", "HM001", "HM001", "HM001", 
"HM001", "HM001", "HM001", "HM001", "HM001", "HM001", "HM001", 
"HM001", "HM001", "HM001"), CTIME = 1223:1237, WEIGHT = c(24.9, 
25.2, 25.5, 25.24132, 25.7, 27.1, 27.3, 27.4, 28.4, 29.2, 30.1377, 
31.17251, 32.4, 33.7, 34.3)), .Names = c("ID", "CTIME", "WEIGHT"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5", 
"6", "7", "8", "9", "10", "11", "12", "13", "14", "15")),
imp2=structure(list(ID = c("HM001", "HM001", "HM001", "HM001", "HM001", 
"HM001", "HM001", "HM001", "HM001", "HM001", "HM001", "HM001", 
"HM001", "HM001", "HM001"), CTIME = 1223:1237, WEIGHT = c(24.9, 
25.2, 25.5, 25.54828, 25.7, 27.1, 27.3, 27.4, 28.4, 29.2, 29.8977, 
31.35045, 32.4, 33.7, 34.3)), .Names = c("ID", "CTIME", "WEIGHT"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5", 
"6", "7", "8", "9", "10", "11", "12", "13", "14", "15")),
imp3=structure(list(ID = c("HM001", "HM001", "HM001", "HM001", "HM001", 
"HM001", "HM001", "HM001", "HM001", "HM001", "HM001", "HM001", 
"HM001", "HM001", "HM001"), CTIME = 1223:1237, WEIGHT = c(24.9, 
25.2, 25.5, 25.46838, 25.7, 27.1, 27.3, 27.4, 28.4, 29.2, 30.88185, 
31.57952, 32.4, 33.7, 34.3)), .Names = c("ID", "CTIME", "WEIGHT"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5", 
"6", "7", "8", "9", "10", "11", "12", "13", "14", "15")))
#It could be combined by:
do.call(rbind, imput1_2_3)# But if you do this the total number or rows will be the sum of the number of rows of each dataset.

I guess you want something like this:

res<-Reduce(function(...) merge(...,by=c("ID","CTIME")),imput1_2_3)
?names(res)[3:5]<- paste("WEIGHT","IMP",1:3,sep="")
?res
#????? ID CTIME WEIGHTIMP1 WEIGHTIMP2 WEIGHTIMP3
#1? HM001? 1223?? 24.90000?? 24.90000?? 24.90000
#2? HM001? 1224?? 25.20000?? 25.20000?? 25.20000
#3? HM001? 1225?? 25.50000?? 25.50000?? 25.50000
#4? HM001? 1226?? 25.24132?? 25.54828?? 25.46838
#5? HM001? 1227?? 25.70000?? 25.70000?? 25.70000
#6? HM001? 1228?? 27.10000?? 27.10000?? 27.10000
#7? HM001? 1229?? 27.30000?? 27.30000?? 27.30000
#8? HM001? 1230?? 27.40000?? 27.40000?? 27.40000
#9? HM001? 1231?? 28.40000?? 28.40000?? 28.40000
#10 HM001? 1232?? 29.20000?? 29.20000?? 29.20000
#11 HM001? 1233?? 30.13770?? 29.89770?? 30.88185
#12 HM001? 1234?? 31.17251?? 31.35045?? 31.57952
#13 HM001? 1235?? 32.40000?? 32.40000?? 32.40000
#14 HM001? 1236?? 33.70000?? 33.70000?? 33.70000
#15 HM001? 1237?? 34.30000?? 34.30000?? 34.30000
A.K.
Message-ID: <1359426338.71488.YahooMailNeo@web142601.mail.bf1.yahoo.com>
In-Reply-To: <2a78b2b0165697ec2c580214cee11@tweb08.nm.nhnsystem.com>