I have two vectors. I want to make a barplot of the first vector (simple enough, right). The twist is that every element of the second vector is the standard deviation for e
I personally like arrows() best for this kind of graphic:
df <- data.frame(bar = c(-4.6521175, 1.1744100, -0.2581400, -0.3452675, -2.3823650, 0.5625125),
error = c(0.145839723, 0.342278694, 0.003776341, 0.073241199, 0.095008502, 0.021627196))
foo <- barplot(df$bar,ylim=c(-6,2),border=NA)
arrows(x0=foo,y0=df$bar+df$error,y1=df$bar-df$error,angle=90,code=3,length=0.1)
Two details:
border=NA in barplot() removes the borders around the bars, so you can actually see the error whiskers around the third bar. Since the third error is so small, the whisker lies pretty much on top of the bar border.
I used the length parameter in arrows() to reduce the width of the horizontal whiskers, which is especially relevant if we have larger numbers of bars. The default is length=0.25.
However, note that "dynamite plots" have major disadvantages. You write that your data come from just four raw points for each bar. In such a case it would almost certainly be better to just plot a (jittered) dotplot of your raw data.