If you reshape your data so that it is in the long format, you can use stat = "summary"
to calculate relevant statistics from the data. What statistics are calculated depend on the fun
/fun.data
argument.
library(ggplot2)
df <- read.table(text = "Time Replicate Media1 Media2
1 T0 R1 0.013733333 0.03770000
2 T0 R2 0.008233333 0.03690000
3 T0 R3 0.013333333 0.03760000
4 T1 R1 0.018166667 0.03680000
5 T1 R2 0.013466667 0.03570000
6 T1 R3 0.018366667 0.03700000
7 T2 R1 0.028066667 0.04420000
8 T2 R2 0.022966667 0.04400000
9 T2 R3 0.027866667 0.04420000
10 T3 R1 0.041333333 0.05536667
11 T3 R2 0.033433333 0.05476667
12 T3 R3 0.039833333 0.05446667")
df <- tidyr::pivot_longer(df, c("Media1", "Media2"))
ggplot(df, aes(Time, value, colour = name)) +
geom_jitter(width = 0.2) +
geom_line(aes(group = name), stat = "summary", fun = mean) +
geom_errorbar(stat = "summary", fun.data = function(x) {
data.frame(ymin = mean(x) - sd(x), ymax = mean(x) + sd(x))
}, width = 0.1)
Created on 2021-01-09 by the reprex package (v0.3.0)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…