Learn R Programming

papaja (version 0.1.0.9054)

apa_barplot: Barplot for factorial designs that conform to APA guidelines

Description

Wrapper function for barplot that creates one or more barplots from a data.frame containing data from a factorial design and sets APA-friendly defaults.

Usage

apa_barplot(data, id, factors, dv, tendency = mean, dispersion = conf_int, level = 0.95, fun_aggregate = mean, na.rm = TRUE, intercept = NULL, ...)

Arguments

data
A data.frame that contains the data.
id
Character. Variable name that identifies subjects.
factors
Character. A vector of up to 4 variable names that is used to stratify the data.
dv
Character. The name of the dependent variable.
tendency
Closure. A function that will be used as measure of central tendency.
dispersion
Closure. A function that will be used to construct error bars (i.e., whiskers). Defaults to conf_int for 95% confidence intervals. See details.
level
Numeric. Defines the width of the interval if confidence intervals are plotted. Defaults to 0.95 for 95% confidence intervals. Ignored if dispersion is not conf_int.
fun_aggregate
Closure. The function that will be used to aggregate observations within subjects and factors before calculating descriptive statistics for each cell of the design. Defaults to mean.
na.rm
Logical. Specifies if missing values are removed. Defaults to TRUE.
intercept
Numeric. Adds a horizontal line to the plot.
...
Further arguments than can be passed to barplot function.

Details

The measure of dispersion can be either conf_int for confidence intervals, se for standard errors, or any other standard function. If conf_int is specified, you can also specify the area of the cumulative distribution function that will be covered. For instance, if you want a 98% confindence interval, specify level = 0.98. level defaults to 0.95.

See Also

barplot

Examples

Run this code
apa_barplot(
   data = npk
   , id = "block"
   , dv = "yield"
   , factors = c("N")
)

apa_barplot(
   data = npk
   , id = "block"
   , dv = "yield"
   , factors = c("N", "P")
)

apa_barplot(
   data = npk
   , id = "block"
   , dv = "yield"
   , factors = c("N", "P", "K")
   , ylim = c(0, 80)
   , level = .34
   , las = 1
)

Run the code above in your browser using DataLab