英文:
How to use the `mean_se()` function to calculate confidence intervals?
问题
我想以编程方式创建95%置信区间。我如何设置geom_errorbar()
中的mean_se
的mult
参数?
mtcars %>%
ggplot(aes(factor(cyl), hp)) +
geom_bar(stat = "summary", fun = mean, na.rm = TRUE)
geom_errorbar(stat = "summary", width = .3)
英文:
I want to programmatically create 95% confidence intervals. How can I set the mult
argument of mean_se
in geom_errorbar()
?
mtcars %>%
ggplot(aes(factor(cyl), hp)) +
geom_bar(stat = "summary", fun = mean, na.rm = TRUE)
geom_errorbar(stat = "summary", width = .3)
答案1
得分: 1
以下是您要翻译的内容:
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
)
Created on 2023-02-15 with reprex v2.0.2
英文:
As a start
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
)
<sup>Created on 2023-02-15 with reprex v2.0.2</sup>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论