0

我有一个看起来像这样的df:

   ID Genotype Time10min  N        mean          sd           se          ci
43  1   k_DMSO        43 10 0.029318750 0.009793853 0.0030970883 0.007006100
44  1   k_DMSO        44 10 0.008825716 0.005164837 0.0016332648 0.003694702
45  1   k_DMSO        45 10 0.008466507 0.002879642 0.0009106228 0.002059972
46  1   k_DMSO        46 10 0.005871386 0.003848483 0.0012169970 0.002753039
47  1   k_DMSO        47 10 0.003126562 0.004755841 0.0015039288 0.003402123
48  1   k_DMSO        48 10 0.005546801 0.003725496 0.0011781053 0.002665059

我想在 y 轴上绘制“平均值”,在 x 轴上绘制“Time10min”的图形。

为此,我想要使用此函数在“基因型”指定的组内的所有平均值:

  ggplot((data_all), aes(x=Time10min, y=mean))+
  stat_summary(aes(group=Genotype, color=Genotype), fun=mean, geom="line", size=2)

我每组得到一条线作为平均值,这就是我想要的。

然后我想添加一个基于 sem 的 geom_ribbon。

我尝试了以下 2 个选项:

  ggplot((data_all), aes(x=Time10min, y=mean))+
  stat_summary(aes(group=Genotype, color=Genotype), fun=mean, geom="line", size=2)+
  geom_ribbon(aes(group=Genotype, fill=Genotype,ymin=mean-se, ymax=mean+se), alpha=0.5)

这给了我一个非常混乱的丝带,看起来像这样: 图形

在更新我的 R 之前有效的其他选项是:

 ggplot((data_all), aes(x=Time10min, y=mean))+
  stat_summary(aes(group=Genotype, color=Genotype), fun=mean, geom="line", size=2)+
  stat_summary(aes(group=Genotype, fill=Genotype),geom="ribbon",fun.data = mean_cl_boot, alpha= 0.5)

现在我不断收到这样的错误:

Warning: Computation failed in `stat_summary()`:

数据类型有:

'data.frame':   36100 obs. of  8 variables:
 $ ID       : int  1 1 1 1 1 1 1 1 1 1 ...
 $ Genotype : Factor w/ 10 levels "w_DMSO","h_DMSO",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ Time10min: int  1 2 3 4 5 6 7 8 9 10 ...
 $ N        : num  10 10 10 10 10 10 10 10 10 10 ...
 $ mean     : num  0.026 0.0341 0.0312 0.0173 0.0114 ...
 $ sd       : num  0.00801 0.0047 0.01085 0.01521 0.00868 ...
 $ se       : num  0.00253 0.00149 0.00343 0.00481 0.00274 ...
 $ ci       : num  0.00573 0.00336 0.00776 0.01088 0.00621 ...

拜托,有人可以帮我在这个情节上弄一条漂亮的丝带吗?

谢谢!

4

0 回答 0