[R] Strange zoo behaviour, possible bug?

Giuseppe Milicia Giuseppe.Milicia at makoglobal.com
Wed Apr 28 17:01:45 CEST 2010


Hi all,

I bumped into this awkward zoo behaviour. I'd be half tempted to call it a bug, what do you think? It's annoying to work around it :( I wonder if this was the behaviour of older zoo versions, I can't remember coming across this sort of thing...

> version
               _
platform       i386-pc-solaris2.10
arch           i386
os             solaris2.10
system         i386, solaris2.10
status
major          2
minor          10.1
year           2009
month          12
day            14
svn rev        50720
language       R
version.string R version 2.10.1 (2009-12-14)

> packageDescription("zoo")
Package: zoo
Version: 1.6-2
Date: 2009-11-23

>t1 = zoo(-100,   as.POSIXct("2009-12-31")+(2:10)*60*60*24)
>t2 = zoo(matrix(0), index(t1)[1]-1)
>colnames(t1)="test"
>colnames(t2) = colnames(t1)

> t1
2010-01-02 2010-01-03 2010-01-04 2010-01-05 2010-01-06 2010-01-07 2010-01-08
      -100       -100       -100       -100       -100       -100       -100
2010-01-09 2010-01-10
      -100       -100
> t2

2010-01-01 23:59:59 0

>rbind(t1,t2)

2010-01-01 23:59:59    0
2010-01-02 00:00:00 -100
2010-01-03 00:00:00    0
2010-01-04 00:00:00 -100
2010-01-05 00:00:00    0
2010-01-06 00:00:00 -100
2010-01-07 00:00:00    0
2010-01-08 00:00:00 -100
2010-01-09 00:00:00    0
2010-01-10 00:00:00 -100
Warning message:
In rbind(c(-100, -100, -100, -100, -100, -100, -100, -100, -100),  :
  number of columns of result is not a multiple of vector length (arg 1)

>rbind(as.xts(t1),as.xts(t2))

                    [,1]
2010-01-01 23:59:59    0
2010-01-02 00:00:00 -100
2010-01-03 00:00:00 -100
2010-01-04 00:00:00 -100
2010-01-05 00:00:00 -100
2010-01-06 00:00:00 -100
2010-01-07 00:00:00 -100
2010-01-08 00:00:00 -100
2010-01-09 00:00:00 -100
2010-01-10 00:00:00 -100

And also:
> t1 = zoo(matrix(-100,ncol=1),   as.POSIXct("2009-12-31")+(2:10)*60*60*24)
> rbind(t1,t2)

2010-01-01 23:59:59    0
2010-01-02 00:00:00 -100
2010-01-03 00:00:00 -100
2010-01-04 00:00:00 -100
2010-01-05 00:00:00 -100
2010-01-06 00:00:00 -100
2010-01-07 00:00:00 -100
2010-01-08 00:00:00 -100
2010-01-09 00:00:00 -100
2010-01-10 00:00:00 -100

Cheers,

//Giuseppe

---- MAKO ----
This email and any files transmitted with it are confide...{{dropped:14}}



More information about the R-help mailing list