r - GGPlot2:按条件分组的误差线
问题描述
使用这些数据:
condition <- c('control', 'control', 'causal', 'causal') # grouping condition
shift <- c('first', 'second') # subgrouping condition
means <- c(-30, 60, -20, 40) # means per group
se <- c(6, 10, 7, 9) # Standard errors per group
plotdata2 <- data.frame(condition, shift, means, se)
我想在下面的图中绘制误差线:
ggplot(plotdata2, aes(x=condition, y=means, fill=shift)) +
geom_bar(stat='identity', width = .6) +
coord_flip()
但是,使用
ggplot(plotdata2, aes(x=condition, y=means, fill=shift)) +
geom_bar(stat='identity', width = .6) +
coord_flip() +
geom_errorbar(aes(ymax = min(se)-0.5, ymin=max(se)+0.5))
不起作用,因为误差线采用 SE 的全局 ymax 和 ymin。如何使用各自条件的 min(se) 和 max(se) 制作两个不同的误差线?
我没有原始数据;因此,我只能使用此摘要。
解决方案
推荐阅读
- python - 将参数传递给 Print
- angular - CORB跨源请求被阻止如何在角度项目中允许
- php - 如何有条件地在两个数组中的对应元素之间执行减法?
- ruby - Change logo image For CASino,一个 Ruby 单点登录解决方案
- excel - 如何从两个单元格中的参考值返回第三列的查找值?
- react-native - 函数作为 React 子级无效(React-Native)
- vbscript - 如何仅将部分程序调用到另一个 vbscript 中?
- vuejs2 - Vuetify 中的占位符
标签不起作用 - npm - brew、cask、pip、npm、composer 等从哪里获得他们的东西,以及什么可以防止恶意软件?
- ios - UIWebview/WKWebivew WebP 支持