error.bars {psych}R Documentation

Plot means and confidence intervals

Description

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.

Usage

error.bars(x, ylab = "Dependent Variable",xlab="Independent Variable", main=NULL, ylim = NULL, alpha=.05, labels = NULL, pos = NULL, arrow.len = 0.05, add = FALSE,bars=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
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

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.

Value

Graphic output showing the means + x

Author(s)

William Revelle

See Also

error.crosses for two way error bars, error.bars.by for error bars for different groups

Examples

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)

error.bars(attitude) #another example
error.bars(attitude,bar=TRUE)  #show the use of bar graphs

#combine with boxplot
boxplot(attitude)
error.bars(attitude,add=TRUE)

#combine with a strip chart
stripchart(attitude,vertical=TRUE,method="jitter")
error.bars(attitude,add=TRUE,arrow.len=.2)

[Package psych version 1.0-67 Index]