Skip to content
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

support for align? #38

Open
japhir opened this issue Jun 22, 2021 · 5 comments
Open

support for align? #38

japhir opened this issue Jun 22, 2021 · 5 comments

Comments

@japhir
Copy link

japhir commented Jun 22, 2021

In #37 you briefly discuss that the package currently only supports zoo's align = "right" option. Are there any plans to support align = "center"? The added value for me would be that this package allows for min_obs, which I couldn't figure out for zoo's implementation.

@japhir
Copy link
Author

japhir commented Jun 22, 2021

To clarify: I did find zoo's partial argument, but couldn't get it to work with fill = NA so that I can force it to return a same-length vector which will fit nicely inside my mutate call.

@jasonjfoster
Copy link
Owner

Thanks for the feedback. I currently don't have plans to support it but we can see whether there's demand or collaborators that want to help.

@jangorecki
Copy link

for align left you can reverse your input vector rev, for align center you should be able to achieve it by shifting answer recalculating missing front/tail of the answer

@roaldarbol
Copy link

I’d love to see alignment too. :-)

A common use of rolling medians is as a smoothing filter in time series. There it's usually expected that the filter is centered to avoid a time shift. For left, it could just be running the right alignment on the reversed vector, and returning the re-reversed vector as suggested by @jangorecki. For center it could maybe be done simply by shifting the returned vector by width/2?

@jangorecki
Copy link

You may want to check https://github.com/Rdatatable/data.table/tree/rollmedian
For odd window size only, as in smoothing, there is very good routine in base R runmed although not sure if it will scale with bigger window sizes. In data.table we implemented a novel algorithm for running median, which scales well also for bigger window sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants