On Sun, 16 Nov 2008, Tolga Uzuner wrote:

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

What happens is the following:
  - There is base:::rbind() and methods:::rbind(). The former is just
    an .Internal() call while the latter additionally does consistency
    checks. The consistency checks require that you can only rbind()
    if the result has a dimension.
  - base:::rbind() is usually found first, even if "methods" is loaded.
    But if you load "timeSeries" this changes and methods:::rbind() is
    found first. I haven't figured out why this happens but it does _not_
    for other S4 packages (such as "Matrix" for example).
  - Thus, if you rbind 1d zoo series, the result is also 1d and has no
    dimension. If "timeSeries" is loaded, methods:::rbind() is called
    which assumes a dimension and fails if there is none.

What should be done:
  - I'm not sure whether "timeSeries" can be changed so that
    base:::rbind() is still found first.
  - Maybe methods:::rbind() could be made more liberal so that it does
    not fail for 1d return values. Of course, one could argue that a row
    bind only makes sense if there are rows and columns. But, then again,
    maybe it is possible to allow other usages as well.
  - You can work around this as a user of zoo series, by calling c()
    instead of rbind() for 1d series, i.e.,
      c(foo, bar)
    always works with or without "timeSeries" attached. Moreover, c()
    even works for 2d zoo series.

hth,
Z

______________________________________________
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