error_bars: Plotting Dots and Error Bars

View source: R/error_bars.R

error_barsR Documentation

Plotting Dots and Error Bars

Description

Insert points and error bars indicating tendency and distribution (error).

This function is using points() to plot the tendency values and segments() for the error bars.

It is also possible to draw just error bars using the option show.tendency=FALSE.

Usage

error_bars(
  tendency,
  upper,
  lower,
  at,
  show.tendency = TRUE,
  bar.col = "black",
  lwd = 1,
  lty = 1,
  ...
)

Arguments

tendency

Numeric vector with tendency values (e.g. mean values).

upper

Numeric vector with values for upper error intervals.

lower

Numeric vector with values for lower error intervals.

at

Numeric vector indicating the position for points.

show.tendency

Logical value indicating whether points should be drawn or not.

bar.col

Color for bars.

lwd

Width of bars (see par).

lty

Line type for bars (see par).

...

Further arguments to be passed to points

Author(s)

Miguel Alvarez (malvarez@uni-bonn.de).

Examples

data(PlantGrowth)

## Calculation of mean and standard deviation
Growth <- aggregate(weight ~ group, PlantGrowth, mean)
Growth$sd <- aggregate(weight ~ group, PlantGrowth, sd)$weight

## Error bars overlaid to boxplots
boxplot(weight ~ group, data = PlantGrowth, border = "grey", main = "Error Bars")
with(
  Growth,
  error_bars(tendency = weight, upper = sd, pch = 21, bg = "red", lwd = 2, cex = 1.5)
)


kamapu/Lexiguel documentation built on July 29, 2022, 7:52 p.m.