Derek Eder
2002-May-15 13:34 UTC
Fwd: Re: [R] Combining many dataframes from listings of objects?
> I want to combine (rbind) many dataframes into a single data frame, but "automatically" > specifying the names of the dataframes as listing of object names. > E.g., combine these 18 df objects into one big df using something conceptually like this : > rbind(objects(pattern="*.df"))Brian Ripley suggested that something along the lines of: do.call("rbind", objects(pattern="*.df")) But I can't make this fly on vectors. E.g.,> objects.of.desire_objects(pattern="*.df") > do.call("rbind.data.frame",list(as.name(objects.of.desire))) # do.call needs a list and must be of class 'name'Unfortunately, only the first data.frame in the series is read and returned. Any further nudges along the right direction anyone? Thanks! Derek N. Eder G?teborgs Universitet Institutionen f?r klinisk neurovetenskap - psykiatri Sahlgrenska universitetssjukhuset SS/SU Bl? straket 17b SE 413 45 G?teborg Sverige Tlf. +46 (031) 34 2-6139 (office) Tlf. +46 (031) 34 2-1283 (laboratory) Tlf. +46 0709 / 7 2-1283 (mobil) Fax. +46 (031) 82 81 63 derek.eder at neuro.gu.se Gothenburg University Institute of Clinical Neuroscience, Section for Psychiatry Salhgrenska Hospital SU/SS SE 413 45 G?teborg Sweden -------------- next part -------------- An embedded message was scrubbed... From: Prof Brian D Ripley <ripley at stats.ox.ac.uk> Subject: Re: [R] Combining many dataframes from listings of objects? Date: Wed, 15 May 2002 10:56:07 +0100 (GMT Daylight Time) Size: 4732 Url: https://stat.ethz.ch/pipermail/r-help/attachments/20020515/a5f0db46/attachment.mht
Peter Dalgaard BSA
2002-May-15 17:06 UTC
Fwd: Re: [R] Combining many dataframes from listings of objects?
"Derek Eder" <Derek.Eder at neuro.gu.se> writes:> > I want to combine (rbind) many dataframes into a single data frame, but "automatically" > > specifying the names of the dataframes as listing of object names. > > E.g., combine these 18 df objects into one big df using something conceptually like this : > > rbind(objects(pattern="*.df")) > > > Brian Ripley suggested that something along the lines of: do.call("rbind", objects(pattern="*.df")) > > > But I can't make this fly on vectors. E.g., > > > objects.of.desire_objects(pattern="*.df") > > do.call("rbind.data.frame",list(as.name(objects.of.desire))) # do.call needs a list and must be of class 'name' > > Unfortunately, only the first data.frame in the series is read and returned. > > > Any further nudges along the right direction anyone?How about this? do.call("rbind", lapply(objects(pattern="*.df"),get)) or eval(as.call(c(as.name(rbind), lapply(objects(pattern="*.df"), as.name)))) (NB: "How about" is code for "Not actually tried"!) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._