# NOT RUN {
set.seed(123456)
df <- data.frame(X = rep(1:20,2),
Y = runif(40),
category = rep(c("A","B"), each = 20))
ggplot(df, aes(x = X, y = Y, colour = category)) +
stat_apply_group(.fun.y = cumsum)
ggplot(df, aes(x = X, y = Y, colour = category)) +
geom_point() +
stat_apply_group(.fun.y = runmed, .fun.y.args = list(k = 5))
ggplot(df, aes(x = X, y = Y, colour = category)) +
stat_apply_panel(.fun.y = function(x) {(x - min(x)) / (max(x) - min(x))})
# }
Run the code above in your browser using DataLab