2
How to include 95% confidence interval in graph columns using ggplot2?
Data frame I’m using
x<-c(0.005, 0.178, 0.031, 0.058, 0.032, 0.196, 0.123, 0.159, 0.474, 0.153, 0.003, 0.012, 0.097, 0.022, 0.143, 0.111, 0.239, 0.008, 0.027, 0.085, 0.115, 0.104, 0.026, 0.072, 0.021, 0.002, 0.019, 0.107, 0.004, 0.182, 0.108, 0.133)
y<-c(-1.0, -1.0, -1.0, -1.0, 0.769, 0.623, -1.0, 0.327, -1.0, -0.638, -1.0, -1.0, -0.618, -1.0, -0.670, -1.0, 0.028, -1.0, -1.0, -1.0, 0.235, -0.286, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.148, 0.857, -0.918)
df<-data.frame(x,y)
Chart I’m using without the confidence interval
ggplot(df, aes(x=reorder(x, y), y))+
geom_bar(stat="identity", aes(fill=y>0), width = .8)+
ylab("y")+
xlab("x")+
theme(axis.text.x = element_text(angle = 90, vjust = 0.6))