Thanks, Gabor. It's a nice workaround. I'll look more at zoo library.

On Fri, Apr 15, 2011 at 7:10 PM, Gabor Grothendieck <ggrothendi...@gmail.com
> wrote:

> On Fri, Apr 15, 2011 at 6:10 PM, zhenjiang xu <zhenjiang...@gmail.com>
> wrote:
> > Thanks, Dennis! I'll go with it. It's surprising there is no ready way to
> do
> > that. I imagine it should be a common data manipulation to add two
> > data.frame from two different sources. It could happen that one
> data.frame
> > is missing some rows while the other have some more.
> >
>
> If you represent them as zoo series then you can do it using +
> (although the definition of + is different than in your post).   Here
> "a", "b" and "c" are the "times":
>
> library(zoo)
> a <- zoo(1:3, letters[1:3])
> b <- zoo(c(6, 1), c("a", "c"))
> a+b
>
> The last line gives:
>
> > a+b
> a c
> 7 4
>
> To use the definition in your post one could do this (which has the
> effect of modifying b so that a+b works as in your post):
>
> merge(a, b, fill = 0, retclass = NULL)
> a+b
>
> The last line gives:
>
> > a+b
> a b c
> 7 2 4
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>



-- 
Best,
Zhenjiang

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to