Re: [R] union of two data frames

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Mon, 25 Feb 2008 23:52:17 +0100 (CET)


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



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. Received on Mon 25 Feb 2008 - 22:57:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Feb 2008 - 00:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive