[英]create a line graph using ggplot2 of the change in mean overtime with 95% CI
My dataset is something like this我的数据集是这样的
df <- data.frame(time = c(0,0,1,1,2,2),
mean = c(8, 6, 7 , 6, 6, 5),
group = c(1,0,1,0,1,0),
lower = c(7, 5, 5, 4, 4, 4),
upper = c(12, 9, 10, 8, 8, 8))
I want to create a plot of the changes in mean at the 3-time points by group, each of which has the corresponding 95% CI (lower, upper), something like this, y-axis is mean, and x-axis is time我想创建一个 plot 按组在 3 个时间点的平均值变化,每个都有相应的 95% CI(下,上),像这样,y 轴是平均值,x 轴是时间
Perhaps like this?也许像这样?
ggplot(df, aes(x = time, y = mean, group = group)) +
geom_line(aes(lty = as.character(group)),
position = position_dodge(width = 0.1)) +
geom_errorbar(aes(ymax = upper, ymin = lower), width = 0.1,
position = position_dodge(width = 0.1)) +
geom_point(aes(shape = as.character(group)),
position = position_dodge(width = 0.1)) +
guides(lty = "none", shape = "none")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.