error.bars {psych} | R Documentation |
One of the many functions in R to plot means and confidence intervals. Can be done using barplots if desired. Can also be combined with such functions as boxplot to summarize distributions. Means and standard errors are calculated from the raw data using describe
.
error.bars(x,stats=NULL, ylab = "Dependent Variable",xlab="Independent Variable", main=NULL, ylim = NULL, alpha=.05, labels = NULL, pos = NULL, arrow.len = 0.05, add = FALSE,bars=FALSE, ...)
x |
A data frame or matrix of raw data |
stats |
Alternatively, a data.frame of descriptive stats from (e.g., describe) |
ylab |
y label |
xlab |
x label |
main |
title for figure |
ylim |
if specified, the limits for the plot, otherwise based upon the data |
alpha |
alpha level of confidence interval – defaults to 95% confidence interval |
labels |
X axis label |
pos |
where to place text: below, left, above, right |
arrow.len |
How long should the top of the error bars be? |
add |
add=FALSE, new plot, add=TRUE, just points and error bars |
bars |
bars=TRUE will draw a bar graph if you really want to do that |
... |
other parameters to pass to the plot function, e.g., typ="b" to draw lines, lty="dashed" to draw dashed lines |
Drawing the mean +/- a confidence interval is a frequently used function when reporting experimental results. By default, the confidence interval is 1.96 standard errors.
Graphic output showing the means + x
William Revelle
error.crosses
for two way error bars, error.bars.by
for error bars for different groups
x <- replicate(20,rnorm(50)) boxplot(x,notch=TRUE,main="Notched boxplot with error bars") error.bars(x,add=TRUE) abline(h=0) error.bars(attitude,alpha=.5,main="50 percent confidence limits") #another example error.bars(attitude,bar=TRUE) #show the use of bar graphs #combine with a strip chart stripchart(attitude,vertical=TRUE,method="jitter",main="Stripchart with 95 percent confidence limits") error.bars(attitude,add=TRUE,arrow.len=.2)