psych (version 1.0-42)

error.bars: Plot means and confidence intervals

Description

One of the many functions in R to plot means and confidence intervals. Meant mainly for demonstration purposes for showing the probabilty of replication from multiple samples. Can also be combined with such functions as boxplot to summarize distributions. Means and standard errors are calculated from the raw data using describe.

Usage

error.bars(x, ylab = "Dependent Variable",xlab="Independent Variable", main="95% confidence limits", ylim = NULL, ci = 1.96, labels = NULL, pos = NULL, arrow.len = 0.05, add = FALSE, ...)

Arguments

x
A data frame or matrix
ylab
y label
xlab
x label
main
title for figure
ylim
if specified, the limits for the plot, otherwise based upon the data
ci
What size confidence interval to use
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
...
other parameters to pass to the plot function, e.g., typ="b" to draw lines, lty="dashed" to draw dashed lines

Value

  • Graphic output showing the means + x

Details

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.

See Also

See Also as error.crosses, error.bars.by

Examples

Run this code
x <- matrix(rnorm(500),ncol=20)
error.bars(x)
#now do a boxplot and then add error bars
x.df <- as.data.frame(x)
boxplot(x.df)
error.bars(x.df, add=TRUE)

Run the code above in your browser using DataLab