[R] inconsistency between timeSeries and zoo causing a problem with rbind

Tolga Uzuner tolga.uzuner at gmail.com
Sun Nov 16 13:59:43 CET 2008


Dear R Users and maintainers of packages zoo and timeSeries,

I believe there is a recently introduced inconsistency between 
timeSeries and zoo which is causing a problem with rbind. I had 
previously reported that I was having problems with rbind in the 
following code:

library(zoo)
foo<-zoo(1,order.by=as.Date("2007-10-09"))
bar<-zoo(2,order.by=as.Date("2007-10-10"))
bar <- rbind(zoo(0, order.by = index(foo)[1]), bar)
bar

Gabor Grothendieck and Dieter Menne tried this code and wrote back 
saying it was working fine. I have also tried this in a fresh session 
and it works fine if the only package I load is zoo. It appears that the 
code fails if one simultaneously loads packages zoo and timeSeries

library(zoo)
library(timeSeries)
foo<-zoo(1,order.by=as.Date("2007-10-09"))
bar<-zoo(2,order.by=as.Date("2007-10-10"))
bar <- rbind(zoo(0, order.by = index(foo)[1]), bar)
bar
sessionInfo()

This leads to the error I had previously reported, please see below. I 
am R 2.8.0, zoo 1.5-4 and timeSeries 280.78.  I believe this is 
potentially a bug: I was not getting this issue even though I have been 
using zoo and timeSeries in the same session since the most recent 
updates to these packages.

Is this a bug ? If so, can it be corrected somehow ?

Thanks in advance,
Tolga

 > library(zoo)

Attaching package: 'zoo'


        The following object(s) are masked from package:base :

         as.Date.numeric

 > library(timeSeries)
Loading required package: timeDate

Attaching package: 'timeSeries'


        The following object(s) are masked from package:zoo :

         time<-

 > foo<-zoo(1,order.by=as.Date("2007-10-09"))
 > bar<-zoo(2,order.by=as.Date("2007-10-10"))
 > bar <- rbind(zoo(0, order.by = index(foo)[1]), bar)
Error in rep.int("", nrow(r)) : incorrect type for second argument 
<<<<<<<<< ERROR
 > bar
2007-10-10
         2
 > sessionInfo()
R version 2.8.0 (2008-10-20)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
Kingdom.1252;LC_MONETARY=English_United 
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] timeSeries_280.78 timeDate_280.80   zoo_1.5-4       

loaded via a namespace (and not attached):
[1] grid_2.8.0      lattice_0.17-15
 >



More information about the R-help mailing list