0

我有一个数据集,我想为其计算几何平均值和自举置信区间。数据具有“状态”和“索引”,范围从 0 到 1。

我想知道:(a)是否有一个选项fun.y = mean可以用 ggplot2 中的特定几何平均函数替换?

(b) 给定这个平均值,如何使用 ggplot 绘制适当的置信区间?

这是我试图计算的代码。

status <- c("low","low","low","low","high","high","high","high")
 index <- c(0.6,0.1,0.6,0.1,0.35,0.35,0.35, 0.35)
df <- data.frame(status, index)


pd <- position_dodge(0.82)
ggplot(df, aes(x=status, y=index, color = status)) + ylim(0,1) + theme_bw() +  geom_point(position = pd, size = 1.5)+   stat_summary(aes(color = status),geom="errorbar", fun.data=mean_cl_boot, width = 0.2, size = 0.8, position = pd)+
   stat_summary(aes(group = status),fun.y=mean, position = pd, geom = "point", size = 4 )
4

0 回答 0