[R] plot a BARPLOT with sd deviation bar up and down

mlell08
Fri, 23 Mar 2012 20:21:19 -0000

Hello,

I think there's no function in R to print error bars.
I once found one in a blog which I'm using.

errorbar <- function(x, y, upper, lower=upper, length=0.02, vert=TRUE, ...){
  if(!doPlot) return()
  if(length(x) != length(y) | length(y) !=length(lower) | length(lower)
!= length(upper))
    stop("vectors must be same length")
  if(vert){
    arrows(x, y+upper, x, y-lower, angle=90, code=3, length=length, ...)
  }else{
    arrows(x+upper, y, x-upper, y, angle=90, code=3, length=length, ...)
  }
}

Regards!