title: Adding errorbars to horizontal barplot in R
body: <p>I would really appreciate help with my little R problem from the community here. I have searched everywhere but have not found a solution yet.</p>
  
  <p>My data looks like this:</p>
  
  <pre><code>trait2 &lt;- c('A','B','C','D')
  rg &lt;- c (0.5480, 0.4801, 0.2805, -0.2480)
  se &lt;- c(0.0495, 0.0908, 0.0548, 0.0957)
  
  trait2   rg      se
  A       0.5480  0.0495
  B       0.4801  0.0908
  C       0.2805  0.0548
  D       -0.2480  0.0957
  </code></pre>
  
  <p>And I ploted a basic barplot using this code:</p>
  
  <pre><code>barplot1 &lt;- barplot(data$rg,
  main="correlation between traits",
  xlab="rG",  
  border="blue", 
  las=1, 
  horiz=TRUE, 
  names.arg=data$trait2, 
  cex.names=0.5,
  xlim=range(-0.4,0.6,0.1) )
  </code></pre>
  
  <p>which works fine:
  <img src="https://i.stack.imgur.com/ViFwm.png" alt="barplot"></p>
  
  <p>But I am having trouble with the error bars using this code:</p>
  
  <pre><code>arrows(barplot1, 
     data$rg- data$se,
     data$rg+ data$se,
     lwd= 1.5,angle=90,code=3,length=0.05)
  </code></pre>
  
  <p>Errorbars appear, but not where they are supposed to appear:
  <img src="https://i.stack.imgur.com/6gITP.png" alt="errobars"></p>
  
  <p>It is probably very simple but I would be very greatful if someone could help me.
  Best, Aron</p>