Fwd: Re: [R] Combining many dataframes from listings of objects?
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Wed May 15 19:06:09 CEST 2002
"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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list