我正在尝试将错误条添加到facet_wrap图中,但似乎没有错误消息似乎无法让R生成我想要的图。我编写了以下代码,生成了我想要的图,但是我似乎无法使代码的errorbar部分正常工作。
ggplot(data = filter(Total, Cell_Line != "stDev"), aes(Time, Killing)) +
geom_line(data = transform(filter(Total, Cell_Line == "Wild_Type"), Cell_Line = NULL), group = 1) +
#geom_errorbar(aes(x = filter(Total, Cell_Line == "Wild_Type")[,2], ymax = filter(Total, Cell_Line == "Wild_Type")[,3] + filter(Total, Cell_Line == "stDev")[,3], ymin = filter(Total, Cell_Line == "Wild_Type")[,3] - filter(Total, Cell_Line == "stDev")[,3]), data = filter(Total, Cell_Line == "Wild_Type" | Cell_Line == "stDev")) +
geom_point(colour = "cadetblue") +
facet_grid_paginate(Cell_Line ~ Run, ncol = 4, nrow = 4)
这段代码生成了情节Sample Plot,这几乎是我想要的,只是缺少黑线上的误差线。
这是我用来生成绘图的数据框的顶部:
Total <-
structure(list(Cell_Line = c("3", "7", "8", "17", "19", "20",
"29", "33", "38", "47", "49", "53", "55", "Wild_Type", "stDev",
"3", "7", "8", "17", "19", "20", "29", "33", "38", "47", "49",
"53", "55", "Wild_Type", "stDev"), Time = c("00", "00", "00",
"00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00",
"00", "02", "02", "02", "02", "02", "02", "02", "02", "02", "02",
"02", "02", "02", "02", "02"), Killing = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0704388, 0.2881066, -0.0132908,
0.04700991, 0.03049371, -0.02243472, 0.1513817, 0.129636, 0.09328508,
0.05876777, 0.1063291, 0.0357473, 0.1974026, 0.07732854, 0.07383331
), Run = c("run1", "run1", "run1", "run1", "run1", "run1", "run1",
"run1", "run1", "run1", "run1", "run1", "run1", "run1", "run1",
"run1", "run1", "run1", "run1", "run1", "run1", "run1", "run1",
"run1", "run1", "run1", "run1", "run1", "run1", "run1")), row.names = c(NA,
30L), class = "data.frame")
这是我收到的当前错误消息:_
错误:美学必须为长度1或与数据相同 (90):x,ymax,ymin