Kaspar Pflugshaupt
2000-Mar-09 08:56 UTC
[R] For the record: how to merge data frames vertically
Hello, to save searching time in the S-news archive, here is the simple solution to merge data frames vertically (cols must be equivalent, of course). The frames must be components of a list, such as produced by framelist<-split(bigframe,factor). bigframe2<-do.call("rbind",framelist) # posted to S-news by Bill Venables, found in summary message http://lib.stat.cmu.edu/s-news/Burst/13564 The result is identical to bigframe with the exception of the rownames. Those seem to be generated by pasting the respective component name and each rowname (maybe to prevent non-unique rownames?). To keep rownames, I use rownames(bigframe2)<-unlist(lapply(framelist,rownames)) Now, all I wonder is, why does this solution work and "rbind(framelist)" does not? (gives "Error in rbind(...) : cannot create a matrix from these types"). To my untrained eye, the two look identical... Cheers Kaspar -- Kaspar Pflugshaupt Geobotanisches Institut Zuerichbergstr. 38 CH-8044 Zuerich Tel. ++41 1 632 43 19 Fax ++41 1 632 12 15 mailto:pflugshaupt at geobot.umnw.ethz.ch privat:pflugshaupt at mails.ch http://www.geobot.umnw.ethz.ch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
2000-Mar-09 09:15 UTC
[R] For the record: how to merge data frames vertically
On Thu, 9 Mar 2000, Kaspar Pflugshaupt wrote:> Hello, > > to save searching time in the S-news archive, here is the simple solution to > merge data frames vertically (cols must be equivalent, of course). TheTo avoid confusion, that is not the usual meaning of `merge', but of concatenate, say.> frames must be components of a list, such as produced by > framelist<-split(bigframe,factor). > > bigframe2<-do.call("rbind",framelist) > > # posted to S-news by Bill Venables, found in summary message > http://lib.stat.cmu.edu/s-news/Burst/13564 > > The result is identical to bigframe with the exception of the rownames. > Those seem to be generated by pasting the respective component name and each > rowname (maybe to prevent non-unique rownames?). To keep rownames, I use > > rownames(bigframe2)<-unlist(lapply(framelist,rownames)) > > Now, all I wonder is, why does this solution work and "rbind(framelist)" > does not? (gives "Error in rbind(...) : cannot create a matrix from these > types"). To my untrained eye, the two look identical...In rbind(framelist) the argument is a single list. do.call creates a call in which framelist is mapped to several arguments. There seems to be a lack of clarity in what cbind and rbind do, and I have expanded the help page for the next patch release. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Apparently Analagous Threads
- Re: [R] R 1.1 congrat; undocumented behaviour of recordPlot (PR#578)
- list of all objects - just being curious
- eqscplot() in library MASS: fails when given only one point (PR#1164)
- html documentation bug in: help(par), 'las'
- Installing contributed packages on MacOS X: Solved!