[R] Merging data.frames

Kaspar Pflugshaupt pflugshaupt at geobot.umnw.ethz.ch
Wed Mar 8 17:26:03 CET 2000


Hello Richard,

I had the a similar problem two weeks ago. In my case, I wanted to re-merge
a dataframe that I had splitted up into a list using split(), then added
variables to each component (the same varnames everywhere). rbind seems to
work only for two dataframes at a time. So, in the end I used

unlist<-function (splitlist)
{
tempframe<-splitlist[[1]]
for (i in 2:length(splitlist))
tempframe<-rbind(tempframe,splitlist[[i]])
tempframe
}

which is not elegant in any way (R-cracks look away), but works. There may
be a very efficient and terse solution for this...

Cheers

Kaspar


> 
> Unfortunately it does not help. I need to concatenate the records vertically,
> not
> horizontally. Each data.frame has the same variables. One data.frame may have
> 10
> records and the other has 20 records. I want a new data.frame with all 30
> records.
> If these were matrices I would use rbind. Unfortunately rbind does not work
> nicely
> with data.frames.
> 


-- 

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list