在R中绘制错误条

在R中绘制错误条,r,statistics,errorbar,R,Statistics,Errorbar,我有以下数据集: conf variable value 1 C1 T1 0.6578166 2 C2 T1 0.6729989 3 C3 T1 0.6629129 4 C4 T1 0.6602419 5 C5 T1 0.6951054 6

我有以下数据集:

            conf    variable        value
1           C1      T1      0.6578166
2           C2      T1      0.6729989
3           C3      T1      0.6629129
4           C4      T1      0.6602419
5           C5      T1      0.6951054
6           C1      T2      0.6764889
7           C2      T2      0.7008580
8           C3      T2      0.6921985
9           C4      T2      0.6868215
10          C5      T2      0.7104877
11          C1      T3      0.6834098
12          C2      T3      0.7120974
13          C3      T3      0.7045760
14          C4      T3      0.6986261
15          C5      T3      0.7180474
16          C1      T4      0.6875082
17          C2      T4      0.7185950
18          C3      T4      0.7122448
19          C4      T4      0.7051376
20          C5      T4      0.7229975
21          C1      T5      0.6902167
22          C2      T5      0.7228775
23          C3      T5      0.7167748
24          C4      T5      0.7093825
25          C5      T5      0.7261777
....
我想将这些数据绘制为带有误差条的线图。为此,我使用了本文中定义的
summarySE
函数。我希望该图是一个直线图,其中x轴表示
变量
,y轴表示
,并按
conf
分组。考虑到从
T1
到当前变量点的值,每个变量都应显示误差条。例如,
T6
中错误条的考虑值应该是
T1
T6
之间的值

基于此,我将
summarySE
函数调用为:

m2 <- summarySE(m, measurevar = "value", groupvars = c("variable","conf") , na.rm=TRUE)
我还尝试了以下方法:

m2 <- summarySE(m, measurevar = "value", groupvars = c("conf") , na.rm=TRUE)
但这并不适用于绘制每个变量的误差条

要绘制绘图,请执行以下操作:

coverage_plot <- ggplot(m2, aes(x=m$variable, y=m$value, group=conf, color=conf)) +
      geom_errorbar(aes(ymin=value-ci, ymax=value+ci), width=0.1, position=pd) +
      geom_line(position=pd) + geom_point(position=pd) +
      scale_x_discrete(labels = c(1:60))

有人能帮我解决这个问题吗

试着像这样在
aes
中删除
$

coverage_plot <- ggplot(m2, aes(x=variable, y=value, group=conf, color=conf)) +
      geom_errorbar(aes(ymin=value-ci, ymax=value+ci), width=0.1, position=pd) +
      geom_line(position=pd) + geom_point(position=pd) +
      scale_x_discrete(labels = c(1:60))

coverage\u绘图您的代码中没有任何错误。你能提供一个可复制的例子吗???@koundy对不起。您的意思是提供绘图吗?是的,请尝试使用一些内置数据集(如iris数据)进行绘图,并在此处显示绘图。您的示例数据在每个变量的每个组中只有一个观察值,您建议如何在没有更多观察值的情况下推导错误?
coverage_plot <- ggplot(m2, aes(x=m$variable, y=m$value, group=conf, color=conf)) +
      geom_errorbar(aes(ymin=value-ci, ymax=value+ci), width=0.1, position=pd) +
      geom_line(position=pd) + geom_point(position=pd) +
      scale_x_discrete(labels = c(1:60))
Error: Aesthetics must be either length 1 or the same as the data (5): ymin, ymax, x, y, group, colour
coverage_plot <- ggplot(m2, aes(x=variable, y=value, group=conf, color=conf)) +
      geom_errorbar(aes(ymin=value-ci, ymax=value+ci), width=0.1, position=pd) +
      geom_line(position=pd) + geom_point(position=pd) +
      scale_x_discrete(labels = c(1:60))