【发布时间】:2019-10-27 20:18:53
【问题描述】:
我正在尝试使用ggplot 创建一个带有置信区间误差线的barplot。本质上,我有一个变量Q1,有 7 个答案选项,我想绘制每个选项的受访者百分比,作为两组(一个和两个)的因素 - 每个组中选择的主题的百分比7 个答案选项中的每一个。
我尝试在ggplot 中将y= count、y=prop 或y=..prop.. 添加到aes,但似乎都不起作用。任何建议表示赞赏。
df5 <- filter(df, Q1!="-99",df$Group=="One"|df$Group=="Two")
ggplot(data = df5, aes(x = Q1)) +
stat_summary(fun.y = mean, geom = "bar") +
stat_summary(fun.data = mean_cl_boot, geom = "errorbar", fun.args = list(mult = 1)) +
geom_bar(aes(label= scales::percent(..prop..),
y= ..prop..,fill = df5$Group), position = "dodge")
错误:stat_summary 需要以下缺失的美学:y。
我实际上是在尝试得到类似这样的东西,误差线代表置信区间。
【问题讨论】:
标签: r ggplot2 bar-chart aesthetics