-
-
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
rollapply with width as a list fails on xts #365
Comments
Thanks for the report! I haven't taken a close look yet, but an (intentional) difference between xts and zoo is that the |
Thanks for the quick feedback. I checked the list(3:5) in both zoo and xts. In xts I got the same error. In zoo it does as expected looks into future. |
Dispatch to rollapply.zoo() when width is a list. Then convert the resulting zoo object back to an xts object, making sure the tzone and tclass attributes are set on the resulting xts object. See #365.
@BibeFiu can you please try the patch on the |
@BibeFiu It would be great if you could try my proposed patch and let me know if it works as expected. You can install the version on the branch from R using the function: |
@joshuaulrich thanks a lot. I tried to install the update with the code you provided I got a |
@BibeFiu: sorry, I made a typo (356 instead of 365 like it should be). Use this command: |
@BibeFiu Did this for you? I'm preparing an xts release and noticed this branch wasn't merged. I'd like to include it in this upcoming release. |
Description
rollapply does not work for xts when the width parameter is a list.
The following example should compute the mean of 3 to 5 elements before,
my_xts <- .xts(1:6,1:6)
rollapplyr(my_xts, width = list(-3:-5), FUN = mean)
but instead reports am error:
Error in rollapply.xts(..., align = align) :
'list' object cannot be coerced to type 'integer'
Expected behavior
But it works if my_xts is converted to zoo:
rollapplyr(as.zoo(my_xts), width = list(-3:-5), FUN = mean)
Minimal, reproducible example
The text was updated successfully, but these errors were encountered: