Let's say I have this:
cplot <- ggplot(mtcars, aes(qsec, wt)) +
geom_point(alpha=0.2)+
stat_smooth(geom='point', n=30, color='red') +
stat_smooth(geom='line', n=30, color='red')
cplot
How can do something similar but computing the mean of the points in each segment instead of fancy regressions?
Note that I don't ask for solutions that involve preprocessing the data. I would like to do this on the fly (if possible).
(the mean of the n-th segment, or with sliding windows, it doesn't really matters since I won't use n=30 but rather 2 or 3 to avoid much distorsions)