Closed teunbrand closed 4 years ago
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)
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 likedunif()
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