Learn R Programming

multicon (version 1.6)

e.bars: Error Bars

Description

A function for plotting error bars onto barplots.

Usage

e.bars(graph, m, ebl, sides = 2, length = 0)

Arguments

graph
A vector of x-coordinates at which to plot the error bars. Alternatively, an object resulting from barplot() may be used.
m
A vector indicating the centers for each error bar (e.g., group means)
ebl
A vector indicating the error bar lengths
sides
A numeric indicating whether one-sided or two-sided error bars are desired.
length
A numeric indicating the length of the "caps" of the error bars

Details

Plots error bars for barplots, but can be used generically for other error bar plotting.

See Also

bargraph

Examples

Run this code
#making random data
y1 <- rnorm(30, mean = 5, sd = 1.5)
y2 <- rnorm(30, mean = 8, sd = 1.2)
#simple barplot
mygraph <- barplot(c(mean(y1),mean(y2)), ylim=c(0,10))
#plotting the error bars 
library(sciplot) # To get the se() function
e.bars(mygraph, c(mean(y1),mean(y2)), ebl=c(se(y1),se(y2)), sides = 2, length = 0.08)

Run the code above in your browser using DataLab