[R] Problem with merging two zoo objects

Achim Zeileis Achim.Zeileis at uibk.ac.at
Fri Oct 15 20:31:12 CEST 2010



On Fri, 15 Oct 2010, Megh Dal wrote:

> Dear all, I have following 2 zoo objects. However when I try to merge those 2 objects into one, nothing is coming as intended. Please see below the objects as well as the merged object:
>
>
>> dat11
>                      V2   V3   V4   V5
> 2010-10-15 13:43:54 73.8 73.8 73.8 73.8
> 2010-10-15 13:44:15 73.8 73.8 73.8 73.8
> 2010-10-15 13:45:51 73.8 73.8 73.8 73.8
> 2010-10-15 13:46:21 73.8 73.8 73.8 73.8
> 2010-10-15 13:47:27 73.8 73.8 73.8 73.8
> 2010-10-15 13:47:54 73.8 73.8 73.8 73.8
> 2010-10-15 13:49:51 73.7 73.7 73.7 73.7
>> dat22
>                      V2   V3   V4   V5
> 2010-10-15 12:09:12 74.0 74.0 74.0 74.0
> 2010-10-15 12:09:33 73.9 73.9 73.9 73.9
> 2010-10-15 12:20:36 74.0 74.0 74.0 74.0
> 2010-10-15 12:30:36 74.0 74.0 74.0 74.0
> 2010-10-15 12:41:03 73.7 73.7 73.7 73.7
>> merge(dat11, dat22)
>                    V2.dat11 V3.dat11 V4.dat11 V5.dat11 V2.dat22 V3.dat22 V4.dat22 V5.dat22
> 2010-10-15 12:09:12       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 12:09:33       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 13:43:54       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 13:44:15       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 13:45:51       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 13:46:21       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 13:47:27       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 13:47:54       NA       NA       NA       NA       NA       NA       NA       NA
> 2010-10-15 13:49:51       NA       NA       NA       NA       NA       NA       NA       NA
> Warning messages:
> 1: In MATCH(x, x) == seq_len(length(x)) :
>  longer object length is not a multiple of shorter object length
> 2: In MATCH(x, x) == seq_len(length(x)) :
>  longer object length is not a multiple of shorter object length
>
> If somebody points me whether I went wrong, it would be really great.

merge() does cbind() (among some more general computations), I guess you 
want rbind().

Try rbind(dat11, dat22).

hth,
Z

> Thanks
>
> ______________________________________________
> 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