[R] How can I declare an empty zoo object?

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jul 31 21:38:46 CEST 2012


On Tue, Jul 31, 2012 at 8:23 AM, arun <smartpink111 at yahoo.com> wrote:
> Hi,
>
> #Without indices
>
>  xzoo<-zoo()
>  x1zoo_f<-zoo(1:10,)
>  cbind(xzoo,x1zoo_f)
>    x1zoo_f
> 1        1
> 2        2
> 3        3
> 4        4
> 5        5
> 6        6
> 7        7
> 8        8
> 9        9
> 10      10
>
>
> #With indices on one
> x1zoo_f<-zoo(1:5,1:10)
>> cbind(xzoo,x1zoo_f)
>    x1zoo_f
> 1        1
> 2        2
> 3        3
> 4        4
> 5        5
> 6        1
> 7        2
> 8        3
> 9        4
> 10       5
>
> #with a different index.  Here, I get warning message.
>
>  x1zoo_f<-zoo(1:5,c(5,6,8,11,13))
>> cbind(xzoo,x1zoo_f)
>    x1zoo_f
> 5        1
> 6        2
> 8        3
> 11       4
> 13       5
> Warning message:
> In merge.zoo(..., all = all, fill = fill, suffixes = suffixes, retclass = "zoo",  :
>   Index vectors are of different classes: integer numeric

Using this will get rid of the warning:

   merge(z, zoo(, numeric(0)))

if you are trying to combine it with a zoo object, z, having a numeric index.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list