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 > >”
Yes, you may have found a bug there in terms of the handling of attributes. On the other hand, who cares?
canddare effectively equal:Inspecting the objects gives nothing away:
I suggest you send a polite mail to the maintainers of
zooillustrating the case.