【发布时间】:2018-08-01 18:11:56
【问题描述】:
alphastats<-summarySE(map, measurevar="shannon", groupvars=c("age_class"))
age_class N shannon sd se ci
1 Non_Smoker 66 5.473424 0.4152997 0.05111986 0.1020934
2 Old_Smoker 47 5.271223 0.6046414 0.08819601 0.1775294
3 Young_Smoker 17 5.324977 0.8682071 0.21057116 0.4463909
嗨,所以我正在尝试将误差线添加到 R 中的 ggplot2 箱线图中。我使用我的三个组中的每一个组的必要标准误差数据创建了上述数据框。
ggplot() +
geom_boxplot(data=map, aes(x=age_class, y=shannon, fill=age_class), na.rm= TRUE ) +
theme_bw() +
geom_jitter(data=map, aes(x=age_class, y=shannon), position=position_jitter(width=0.1)) +
labs(x="Group", y="Shannon Value") +
guides(fill=guide_legend(title="Group Type")) +
annotate("text", x=0.75, y=3.5, size=3, label=paste0("p-value =",alpha_p_round)) +
geom_errorbar(data=alphastats, aes(ymin=shannon-se, ymax=shannon+se))
当我尝试通过 gg_errorbar() 添加错误栏时,我得到了错误:
" eval(expr, envir, enclos) 中的错误:找不到对象'x'
另外:警告信息:
1: 在 min(x, na.rm = na.rm) :
min 没有非缺失参数;返回Inf
2:在 max(x, na.rm = na.rm) 中:
max 没有非缺失参数;返回 -Inf
3: 在 min(diff(sort(x))) 中:min 没有非缺失参数;返回
Inf
谁能帮我弄清楚我做错了什么?
【问题讨论】:
-
您的示例代码不可重现。
map和alpha_p_round未定义。 -
请查看How to create a Minimal, Complete, and Verifiable example,然后相应地编辑您的问题。