#' 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, ...)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.