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,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, ...)
```

### Arguments

 `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

### 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

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

### Examples

```x <- replicate(20,rnorm(50))
boxplot(x,notch=TRUE,main="Notched boxplot with error bars")