[R] union of two data frames

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon Feb 25 23:52:17 CET 2008


On Mon, 25 Feb 2008, stephen sefick wrote:

> DateTime var1 var2 var3 var4 var5 var6
>      .         .        .      .     .      .      .
>      .         .         .      .    .      .      .
>      .         .        .     .      .       .     .
> 1/5/06      1     2     3     4     5     6
> 1/6/06      1     2     3     4     5     6
> 1/7/06      3     4     5     6     7     8
> 1/8/06      4     5     6     7     8     9
>
>
>
> DateTime var1 var2 var3 var4 var5 var6
> 1/5/06      1     2     3     4     5     6
> 1/6/06      1     2     3     4     5     6
> 1/7/06      3     4     5     6     7     8
> 1/8/06      4     5     6     7     8     9
>      .         .        .      .     .      .      .
>      .         .         .      .    .      .      .
>      .         .        .     .      .       .     .

I would recommend to turn your data into a "zoo" series using a "Date"
index (based on your DateTime column).

If the overlap of both series is as simple as above, simply omit the
repeated observations and do an rbind().

If the overlap is more difficult, I would suggest to merge() the series
and then make the appropriate computations variable by variable. See
help("merge.zoo", package = "zoo") and the package vignettes for more
examples.

Best,
Z

>
> I would like to combine two data frames similar to these
>
> On Mon, Feb 25, 2008 at 5:08 PM, Erik Iverson <iverson at biostat.wisc.edu> wrote:
> > You probably need to provide an example here, show us your data.frame
> >  column names, and what you mean by 'common subset of the same data' at
> >  least.  What did you try and what did it do that you didn't expect?
> >
> >
> >
> >  stephen sefick wrote:
> >  > I have a thirty thousand row data frame imported from excel and a
> >  > 60,000 row data frame imported from excel.  they share a common subset
> >  > of the same data and I would like to combine the two into one data
> >  > frame merged together on the data in common.  I have looked at the
> >  > help file for merge and intersect and cbind and rbind etc... And I
> >  > can't figure it out.  Thanks in advance
> >  >
> >  > Stephen
> >  >
> >
>
>
>
> --
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
> 								-K. Mullis
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list