R/error.bar.R

Defines functions error.bar

Documented in error.bar

#' Add error bars onto barplot
#' 
#' @param x A matrix object output from barplot() function.
#' @param y A numeric vector of Y-axis variable (typically mean)
#' @param upper A numeric of vertical lenght of upper error bars
#' @param lower A numeric of vertical lenght of lower error bars. Defults to upper.
#' @param length A vector of lengths of the edges of the arrow head (in inches). Defults to 0.1.
#' @export

error.bar <- function(x, y, upper, lower=upper, length=0.1,...){
  if(length(x) != length(y) | length(y) !=length(lower) | length(lower) != length(upper))
    stop("vectors must be same length")
  arrows(x,y+upper, x, y-lower, angle=90, code=3, length=length, ...)
}
msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.