Closed ethanbsmith closed 9 months ago
This is due to the as.matrix()
call in as.vector.zoo()
:
as.vector.zoo <- function(x, mode = "any") {
as.vector(as.matrix(x), mode = mode)
}
This function hasn't been altered since it was added in r18 "first version that passes R CMD check" on 2004-10-08. This was before coredata()
was introduced.
@zeileis what do you think about changing the as.matrix()
call to coredata()
in the above function? Then it would be:
as.vector.zoo <- function(x, mode = "any") {
as.vector(coredata(x), mode = mode)
}
After looking at as.matrix.zoo()
, I don't think this would be a breaking change. The first line of that function is y <- as.matrix(coredata(x), ...)
. The rest of as.matrix.zoo()
handles setting dims, colnames, and rownames on the result. But we're just going to call as.vector()
on the result, which will drop those attributes anyway. Thoughts?
Good idea! Thanks for pointing this out Ethan @ethanbsmith and for doing the additional digging Josh @joshuaulrich !
I agree and have just committed the fix to the R-Forge version of zoo
, revision 1192.
Fixed upstream in zoo.
Description
i noticed some odd timings on
as.vector()
on an xts objectExpected behavior
same performance as as.vector on a matrix
base r will dispatch to this
Minimal, reproducible example
Session Info