http://adv-r.had.co.nz/Reproducibility.html
and please do not post in Html. John Kane Kingston ON Canada > -----Original Message----- > From: newrnew...@hotmail.com > Sent: Mon, 11 May 2015 20:16:40 +0000 > To: r-help@r-project.org > Subject: [R] binding two lists of lists of dataframes together > > Hi, > I'm new to R and am stumped. I'm trying to bind List 1 to List 2 and > have the corresponding Output. > > I've found the following code - I can't say I understand > rbindlist(lapply(list12, "[", i, TRUE)). Either way - it doesn't give > exactly what's needed. > > library(data.table) > list12 <- list(List1,List2) > nr <- as.vector(nrow(list12[[1]])) > fastbind.ith.rows <- function(i) rbindlist(lapply(list12, "[", i, TRUE)) > fastbound <- lapply(1:nr, fastbind.ith.rows) > > It produces Output 2 - where dataframes are grouped together by rownames, > but keeps 2 separate vectors - vs. binding the two into 1 vector. > > Any help/guidance would be greatly appreciated!! > > Thanks! > Vince > > > List1List2Output (Wanted) V1V2V3 V1V2V3 > V1V2V3idc(563,623,581)c(563,623,581)c(563,623,581)idc(217, 120, > 372)c(125, 334, 86)c(130, 349, 576)idc(563,623,581,217, 120, > 372)c(563,623,581,125, 334, 86)c(563,623,581,130, 349, 576)wgtbandc(0, > 0, 0, 0, 0)c(0, 0, 0, 0, 0)c(0, 0, 0, 0, 0)wgtbandc(1, 2, 3)c(1, 2, > 3)c(1, 2, 3)wgtbandc(0, 0, 0, 0, 0,1, 2, 3)c(0, 0, 0, 0, 0,1, 2, > 3)c(0, 0, 0, 0, 0,1, 2, 3)wgtc(0.007956164, 0.00199414, 0.009970699, > 0.00994571, 0.011994826)c(0.007956164, 0.00199414, 0.009970699, > 0.00994571, 0.011994826)c(0.007956164, 0.00199414, 0.009970699, > 0.00994571, 0.011994826)wgtc(0.003565190625, 0.003565190625, > 0.003565190625)c(0.003565190625, 0.00514971979166667, > 0.003565190625)c(0.003565190625, 0.003565190625, > 0.00514971979166667)wgtc(0.007956164, 0.00199414, 0.009970699, > 0.00994571, 0.011994826,0.003565190625, 0.003565190625, > 0.003565190625)c(0.007956164, 0.00199414, 0.009970699, 0.00994571, > 0.011994826,0.003565190625, 0.00514971979166667,! > 0.003565190625)c(0.007956164, 0.00199414, 0.009970699, 0.00994571, > 0.011994826,0.003565190625, 0.003565190625, 0.00514971979166667)heldc(2, > 2, 2, 2, 2)c(2, 2, 2, 2, 2)c(2, 2, 2, 2, 2)heldc(0, 0, 0)c(0, 0, > 0)c(0, 0, 0)heldc(2, 2, 2, 2, 2,0, 0, 0)c(2, 2, 2, 2, 2,0, 0, 0)c(2, > 2, 2, 2, 2,0, 0, 0)efficiencyc(765, 1660, 1539, 1377, 1452)c(765, 1660, > 1539, 1377, 1452)c(765, 1660, 1539, 1377, 1452)efficiencyc(1292, 908, > 1283)c(1292, 908, 1283)c(1292, 908, 1283)efficiencyc(765, 1660, 1539, > 1377, 1452,1292, 908, 1283)c(765, 1660, 1539, 1377, 1452,1292, 908, > 1283)c(765, 1660, 1539, 1377, 1452,1292, 908, 1283)couponc(4, 11, 16, > 27, 48)c(4, 11, 16, 27, 48)c(4, 11, 16, 27, 48)couponc(735, 403, > 1366)c(414, 1183, 284)c(435, 1222, 127)couponc(4, 11, 16, 27, 48,735, > 403, 1366)c(4, 11, 16, 27, 48,414, 1183, 284)c(4, 11, 16, 27, 48,435, > 1222, 127) > Output2 from Sample Code > V1V2V3idc(563,623,581)c(563,623,581)c(563,623,581)c(217, 120, 372)c(125, > 334, 86)c(130, 349, 576)wgtbandc(0, 0, 0, 0, 0)c(0, 0, 0, 0, 0)c(0, > 0, 0, 0, 0)c(1, 2, 3)c(1, 2, 3)c(1, 2, 3)wgtc(0.007956164, 0.00199414, > 0.009970699, 0.00994571, 0.011994826)c(0.007956164, 0.00199414, > 0.009970699, 0.00994571, 0.011994826)c(0.007956164, 0.00199414, > 0.009970699, 0.00994571, 0.011994826)c(0.003565190625, 0.003565190625, > 0.003565190625)c(0.003565190625, 0.00514971979166667, > 0.003565190625)c(0.003565190625, 0.003565190625, > 0.00514971979166667)heldc(2, 2, 2, 2, 2)c(2, 2, 2, 2, 2)c(2, 2, 2, 2, > 2)c(0, 0, 0)c(0, 0, 0)c(0, 0, 0)efficiencyc(765, 1660, 1539, 1377, > 1452)c(765, 1660, 1539, 1377, 1452)c(765, 1660, 1539, 1377, > 1452)c(1292, 908, 1283)c(1292, 908, 1283)c(1292, 908, 1283)couponc(4, > 11, 16, 27, 48)c(4, 11, 16, 27, 48)c(4, 11, 16, 27, 48)c(735, 403, > 1366)c(414, 1183, 284)c(435, 1222, 127) > > > > > > > > > > > > > > > > > > > > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.