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

Rolling statistics #10

Closed
teunbrand opened this issue Apr 29, 2020 · 1 comment
Closed

Rolling statistics #10

teunbrand opened this issue Apr 29, 2020 · 1 comment
Labels
enhancement New feature or request plan This probably will be worked out in the future

Comments

@teunbrand
Copy link
Owner

teunbrand commented Apr 29, 2020

There should probably be a stat_roll() that can calculate rolling statistics given some kernel function.
The kernel function should then accept a measure of centrality and a measure of spread. A simple moving average would then be a uniform kernel like dunif() but parameterised slightly the mean and distance to extremes.

Rough sketch for rolling Gaussian kernel here:
https://github.com/teunbrand/tidytuesdayscripts/blob/452451997d819564dc201c7c7f93bbf806a2564c/scripts/2020_04_28_Broadway_Grosses.R#L39-L69

@teunbrand teunbrand added enhancement New feature or request plan This probably will be worked out in the future labels Apr 29, 2020
teunbrand added a commit that referenced this issue Jun 2, 2020
@teunbrand
Copy link
Owner Author

This now works

library(ggplot2)
library(ggh4x)

ggplot(mpg, aes(displ, hwy, colour = class)) +
  geom_point() +
  stat_rollingkernel(aes(alpha = after_stat(scaled)))

Created on 2020-06-02 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plan This probably will be worked out in the future
Projects
None yet
Development

No branches or pull requests

1 participant