Learn R Programming

papaja (version 0.1.0.9492)

apa_lineplot: Lineplot for factorial designs that conform to APA guidelines

Description

Wrapper function that creates one or more lineplots from a data.frame containing data from a factorial design and sets APA-friendly defaults. It sequentially calls plot, axis, points, lines, arrows and legend, that may be further customized.

Usage

apa_lineplot(data, id, factors, dv, tendency = mean, dispersion = conf_int,
  level = 0.95, fun_aggregate = mean, na.rm = TRUE, intercept = NULL,
  args_axis = list(), args_points = list(), args_lines = list(),
  args_arrows = list(), args_legend = list(), ...)

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. Can be either a single value or a matrix. For the matrix case, multiple lines are drawn, where the dimensions of the matrix determine the number of lines to be drawn.

args_axis

An optional list that contains further arguments that may be passed to axis

args_points

An optional list that contains further arguments that may be passed to points

args_lines

An optional list that contains further arguments that may be passed to lines

args_arrows

An optional list that contains further arguments that may be passed to arrows

args_legend

An optional list that contains further arguments that may be passed to legend

...

Further arguments than can be passed to plot 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
# NOT RUN {
apa_lineplot(
   data = npk
   , id = "block"
   , dv = "yield"
   , factors = c("N")
)

apa_lineplot(
data = npk
 , id = "block"
 , dv = "yield"
 , factors = c("N", "P")
 , args.legend = list(x = "center")
 , jit = 0
)

apa_lineplot(
   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