We have some data which represents many model runs under different scenarios. For a single scenario, we\'d like to display the smoothed mean, with the filled areas representing
hi i'm not sure if I correctly understand what you want, but for example,
d <- data.frame(Time=rep(1:20, 4),
Value=rnorm(80, rep(1:20, 4)+rep(1:4*2, each=20)),
Run=gl(4,20))
mean_se <- function(x, mult = 1) {
x <- na.omit(x)
se <- mult * sqrt(var(x) / length(x))
mean <- mean(x)
data.frame(y = mean, ymin = mean - se, ymax = mean + se)
}
ggplot( d, aes(x=Time,y=Value) ) + geom_line( aes(group=Run) ) +
geom_smooth(se=FALSE) +
stat_summary(fun.data=mean_se, geom="ribbon", alpha=0.25)
note that mean_se is going to appear in the next version of ggplot2.