【发布时间】:2021-08-29 13:26:48
【问题描述】:
我创建了一个图表,其中包含每个人的曲线和以相同方式创建的平均曲线。我想在我的平均曲线上有一个置信区间。我怎样才能做到这一点?是否应该以不同的方式创建平均曲线? 到目前为止,这是我的代码:
DNAMorfR %>%
drop_na(`Normal morphology (%)`) %>%
ggplot(aes(x = Time, y = `Normal morphology (%)`, linetype = Patient, color = Patient, group
= Patient, na.rm = TRUE)) +
geom_line(size = 1) +
theme_minimal() + ggtitle("(A1) Normal morphology") +
geom_point(size = 1.5) +
scale_y_continuous(limits = c(0, 25), breaks=seq(0, 25, by = 5)) +
geom_hline(yintercept = 4, color = "grey", size = 1) +
scale_color_manual(values = c("black", "#FF3333", "#FF9933", "#CC9900"))
这是我的数据:
data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
Patient = c("1","1","1","2","2","2","3","3","3","mean","mean","mean"),
`Normal morphology (%)` = c(7, 2, 3, 1, 3, 3, 6, 7, 8, 7, 9, 8),
Time = as.factor(c("Week 1","Week 2","Week 3","Week 1","Week 2","Week 3","Week 1","Week 2",
"Week 3","Week 1","Week 2","Week 3")))
【问题讨论】:
标签: r ggplot2 tidyverse mean intervals