-
-
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
subset xts by logical matrix throws an error #331
Comments
Thanks for the report! I would say this is a bug, because it works with zoo objects: library(xts)
z <- cbind(Z = zoo(1:3, Sys.Date()+1:3), X = c(NA,NA,NA))
z[is.na(z),] # returns empty zoo object So this should behave similarly to zoo objects instead of throwing an error. |
Also, this isn't related to set.seed(21)
x <- .xts(matrix(rnorm(6),3), 1:3)
m <- coredata(x) < 0
x[m] # error
as.zoo(x)[m] # empty zoo object |
It would also help to know your use case. I'm not sure zoo does what you expect either, but at least it doesn't error. We may need to create a feature request for the behavior you want. |
Well, I made a workaround for my case already. I am creating various financial indicators, some of them occasionally produce values that are either infinite or not a number (NaN can be considered as NA). So I had to develop a way to treat those exceptions at the time they are calculated rather than at the time they are already sitting in the xts table. However, the expression |
This no longer works w/ zoo btw (R 4.0.4 and zoo package release 1.8-8) |
Thanks for pointing that out @MaxineTheCat. @ggrothendieck and @zeileis, was this an intended change in zoo? |
Achim recently verified that this is due to a change in R where the class
vector of matrices has been
changed (extended) in R.
It is not due to any change in zoo.
there is more discussion here:
https://stackoverflow.com/questions/66468254/error-when-performing-an-na-replacement-in-r-4-0/66488041#66488041
|
On Fri, 5 Mar 2021, ggrothendieck wrote:
Acihm recently verified that this is due to a change in R where the class
vector of matrices has been
changed (extended) in R.
It is not due to any change in zoo.
there is more discussion here:
https://stackoverflow.com/questions/66468254/error-when-performing-an-na-re
placement-in-r-4-0/66488041#66488041
Regards.
The problem was that [.zoo and [<-.zoo for some reason used
all(class(i) == "matrix")
to check whether "i" is a matrix. I've replaced this by
inherits(i, "matrix")
The issue is fixed on R-Forge and I've sent it to the Win-Builder prior to
making a new CRAN release.
…
On Fri, Mar 5, 2021 at 11:35 AM Joshua Ulrich ***@***.***>
wrote:
> This no longer works w/ zoo btw (R 4.0.4 and zoo package release 1.8-8)
>
> Thanks for pointing that out @MaxineTheCat
> <https://github.com/MaxineTheCat>. @ggrothendieck
> <https://github.com/ggrothendieck> and @zeileis
> <https://github.com/zeileis>, was this an intended change in zoo?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#331 (comment)>,
> or unsubscribe
><https://github.com/notifications/unsubscribe-auth/AB32F7TR7F6OIHQSGCBGM7LT
CEB37ANCNFSM4L7WY3TQ>
> .
>
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, orunsubscribe.[AOSLJDXVV3SU24GWQ3YMNKTTCECVPA5CNFSM4L7WY3T2YY3PNVWWK3TUL52HS4
DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF4W6YXA.gif]
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target":
"#331 (comment)",
"url":
"#331 (comment)",
"name": "View Issue" }, "description": "View this Issue on GitHub",
"publisher": { ***@***.***": "Organization", "name": "GitHub", "url":
"https://github.com" } } ]
|
Description
I get an error from the following code:
Is it a bug in the xts package?
Expected behavior
the code is supposed to list all the values of the xts object == NA
It would also be great if it could work for is.finite() and is.infinite() and is.nan()
just as an example, this works for data.frames:
Minimal, reproducible example
Session Info
The text was updated successfully, but these errors were encountered: