-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
as.matrix.xts fails when zero columns #130
Comments
Thanks for the report. Here's a simplified example: R> as.matrix(xts::.xts(,1))
Error in dimnames(cd) <- list(as.character(index(x)), colnames(x)) :
'dimnames' applied to non-array Versus what you get with R> as.matrix(zoo::zoo(,1))
1
R> str(as.matrix(zoo::zoo(,1)))
num[1, 0 ]
- attr(*, "dimnames")=List of 2
..$ : chr "1"
..$ : NULL I think your proposed function provides similar results, but I'll likely follow the pattern in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
xts:::as.matrix.xts
function (xts/R/matrix.R
Line 23 in 016b7cd
A first try at a patch looks like:
I think it needs to be a bit more generic? But this was enough for me, and fixes a unit test that was complaining:
The text was updated successfully, but these errors were encountered: