On Tuesday, March 07, 2000 5:40 PM, Richard Bilonick wrote:>I need to merge several data.frames into one data.frame. In S-Plus I would >use >"merge" but I don't see a merge command in R. What is the best way to >accomplish >this?The easiest way to to this, I think, is as follows: if you have several data frames, dataframe1, dataframe2, . . . , dataframen, you can merger them all into one dataframe by using the data.frame command again with the individuaal data.frames as arguments: data.frame(dataframe1, dataframe2, . . . , dataframen) here's a quick example:> a1_c(1, 1, 1) > a2_c(2, 2, 2) > b1_c(3, 3, 3) > b2_c(4, 4, 4)> adf_data.frame(a1,a2) > bdf_data.frame(b1,b2) > adf+bdfa1 a2 1 4 6 2 4 6 3 4 6> data.frame(adf, bdf)a1 a2 b1 b2 1 1 2 3 4 2 1 2 3 4 3 1 2 3 4> data.frame(adf, bdf, adf)a1 a2 b1 b2 a1 a2 1 1 2 3 4 1 2 2 1 2 3 4 1 2 3 1 2 3 4 1 2 I hope this helps. Mark J. Lamias Department of Statistics Department of Political Science Survey Methodology Program/Survey Research Center Institute for Social Research - University of Michigan 426 Thompson Street, Room 315 Ann Arbor, Michigan 48104-2321 (734) 647-5381 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Mark Lamias wrote:> On Tuesday, March 07, 2000 5:40 PM, Richard Bilonick wrote: > > >I need to merge several data.frames into one data.frame. In S-Plus I would > >use > >"merge" but I don't see a merge command in R. What is the best way to > >accomplish > >this? > > The easiest way to to this, I think, is as follows: > > if you have several data frames, dataframe1, dataframe2, . . . , dataframen, > you can merger them all into one dataframe by using the data.frame command > again with the individuaal data.frames as arguments: > > data.frame(dataframe1, dataframe2, . . . , dataframen) > > here's a quick example: > > > a1_c(1, 1, 1) > > a2_c(2, 2, 2) > > b1_c(3, 3, 3) > > b2_c(4, 4, 4) > > > adf_data.frame(a1,a2) > > bdf_data.frame(b1,b2) > > adf+bdf > a1 a2 > 1 4 6 > 2 4 6 > 3 4 6 > > data.frame(adf, bdf) > a1 a2 b1 b2 > 1 1 2 3 4 > 2 1 2 3 4 > 3 1 2 3 4 > > data.frame(adf, bdf, adf) > a1 a2 b1 b2 a1 a2 > 1 1 2 3 4 1 2 > 2 1 2 3 4 1 2 > 3 1 2 3 4 1 2 > > I hope this helps. > > Mark J. Lamias > Department of Statistics > Department of Political Science > Survey Methodology Program/Survey Research Center > Institute for Social Research - University of Michigan > 426 Thompson Street, Room 315 > Ann Arbor, Michigan 48104-2321 > (734) 647-5381 > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._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. Rick Bilonick -- Statistical Consulting for Business & Industry mailto:rab at nauticom.net efax: 508 445 5821 voice: 412 831 4509 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Wed, 08 Mar 2000 15:13:38 +0000 > From: "Richard A. Bilonick" <rab at nauticom.net> > > I would gladly upgrade to 1.0.0 if I could find an i386 RPM for it. I'vesearched> everywhere and can't find one. The closest I've come isR-base-0.99.0.4.i386.rpm.>You can of course build it quite easily from scratch. What would worry me is that there are differences between Linux installations that are quite considerable, so `an i386 RPM' is about as much use as `a i386 compiler'. If you are using Redhat or Suse, look in the obvious places, any cran node/bin/linux/redhat/6.x/i386 any cran node/bin/linux/suse/6.3/i386 -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._