有没有办法重新定位误差线?

时间:2019-12-05 10:33:00

标签: r ggplot2 bar-chart errorbar

Here is a picture of the barplot I have been able to make up until now with ggplot2.但是,误差线是沿着变量设置的,而不是沿着每个变量按2分组的相应条设置的。我该如何解决这个问题?感谢您的帮助!

这是相关的摘要:

bar_data<- data.frame("Type"=c("Integrated", "Integrated Abroad"), "Year FE"=c(0.382,0.097), 
"Downstr. x Upstr."=c(0.249,0.068), "Firm Controls"=c(0.201,0.058))
bar_data_long<-melt(bar_data, id.vars = "Type")
bar_data_long$se=c( 0.069,0.015,0.064,0.014,0.065,0.014)




bar_chart<- ggplot(bar_data_long, aes(x=variable, y=value)) + 
  geom_bar(stat = "identity", aes(fill=Type), position= "dodge") + 
  scale_color_discrete("Type") +
  xlab("Control Variable") + ylab("Value") +
  geom_errorbar(stat = "identity", aes(ymin=bar_data_long$value-1.96*bar_data_long$se, 
  ymax=bar_data_long$value+1.96*bar_data_long$se), width=0.5)

0 个答案:

没有答案