R语言 如何使用'mean_se()'函数计算置信区间?

xe55xuns  于 2023-02-17  发布在  其他
关注(0)|答案(1)|浏览(232)

我想通过编程创建95%的置信区间,如何在geom_errorbar()中设置mean_semult参数?

mtcars %>% 
  ggplot(aes(factor(cyl), hp)) +
  geom_bar(stat = "summary", fun = mean, na.rm = TRUE)
  geom_errorbar(stat = "summary", width = .3)
bxpogfeg

bxpogfeg1#

作为开始

library(ggplot2)
  ggplot(mtcars, aes(factor(cyl), hp)) +
  geom_bar(stat = "summary", fun = mean, na.rm = TRUE) +
  stat_summary(
    fun.data = "mean_se",
    fun.args = list(mult = 1.96),
    geom = "errorbar",
    width = 0.3
  )

创建于2023年2月15日,使用reprex v2.0.2

相关问题