[R] appending similar data frames?

Duncan Murdoch murdoch at stats.uwo.ca
Mon Dec 3 22:29:53 CET 2001

On 03 Dec 2001 14:35:54 -0500, you wrote in message
<87adx06qqt.fsf at lumen.med.iupui.edu>:

>Dear R gang,
>Can anyone help me sort out how to append one data frame to
>another while adding a factor to distinguish which was the
>original frame?

As long as the names match exactly in the two original frames, you
should be able to do it using "rbind" and "cbind":


 rbind( cbind(x, 'x'), cbind(y, 'y') )

What the cbind's are doing is adding a column to the original
dataframes giving their name.  Then the rbind glues the two dataframes

If the names don't match exactly, then you should rename things so
they do.

Duncan Murdoch
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