rbind.zoo doesn't seem create consistent zoo object

Posted by a-or-b on Stack Overflow See other posts from Stack Overflow or by a-or-b
Published on 2009-12-14T03:54:14Z Indexed on 2010/03/30 11:03 UTC
Read the original article Hit count: 212

Filed under:

I want to rbind.zoo two zoo object together. When I was testing I came across the following issue(?)...

Note: The below is an example, there is clearly no point to it apart from being illustrative. I have an zoo object, call it, 'X'. I want to break it into two parts and then rbind.zoo them together. When I compare it to the original object then all.equal gives differences.

It appears that the '$class' attribute differs, but I can't see how or why. Is I make these xts objects then the all.equal works as expected.

i.e. .....

X.date <- as.POSIXct(paste("2003-", rep(1:4, 4:1), 
                     "-", sample(1:28, 10, replace = TRUE), sep = ""))

X <- zoo(matrix(rnorm(24), ncol = 2), X.date)

a <- X[c(1:3), ]      # first 3 elements

b <- X[c(4:6), ]      # second 3 elements

c <- rbind.zoo(a, b)  # rbind into an object of 6 elements

d <- X[c(1:6), ]      # all 6 elements

all.equal(c, d)       # are they equal?

~~~~

all.equal gives me the following difference:

"Attributes: < Component 3: Attributes: < Length mismatch: comparison on first 1 components > >"

© Stack Overflow or respective owner

Related posts about r