wrap.line: Line plots

View source: R/wrap.line.R

wrap.lineR Documentation

Line plots

Description

Creates line plots for numerical dependent variables, adds error bars, and prints descriptive statistics in a summary table. The function creates plots for up to 3 factors total, including 1 within-subjects factor (corresponding to the default path of each line) and 0-2 between-subjects factors. The function delegates the primary computations to ggplot.

Usage

wrap.line(
  dv1,
  iv1 = NULL,
  iv2 = NULL,
  errorbar = "se",
  ylim = NULL,
  ymajor = NULL,
  ylab = NULL,
  xlab = NULL,
  title = NULL,
  size.axis.text.y = 12,
  size.axis.text.x = 16,
  size.title = 24,
  size.panel.title = 12,
  size.legend.text = 14,
  reposition = NULL,
  rename1 = NULL,
  rename2 = NULL,
  rename3 = NULL,
  reorder1 = NULL,
  reorder2 = NULL,
  reorder3 = NULL
)

Arguments

dv1

Multiple column vectors containing the within-subjects dependent variables

iv1, iv2

Column vectors containing the independent variables

errorbar

Character string specifying the length of the error bars: "se" displays +/-1 standard error; "ci" displays 95% confidence intervals without p-value adjustment; "none" omits error bars

ylim

Numeric vector containing lower and upper y-axis limits

ymajor

Numeric argument representing spacing of y-axis tick marks

ylab

Character string containing the y-axis label

xlab

Character string containing the x-axis label

title

Character string containing the plot title

size.axis.text.y, size.axis.text.x, size.title, size.panel.title, size.legend.text

Numeric arguments containing font sizes

reposition

Numeric vector to rearrange columns in the summary table and thus reposition factors within the plot itself. For example, reposition = c(1, 3, 2) reverses the order of the second and third columns in the summary table and repositions the corresponding factors within the plot. The length of the reposition vector must equal the total number of within-subjects and between-subjects factors.

rename1, rename2, rename3

String vectors to rename the factor levels in the summary table and thus rename factor levels within the plot itself. For example, rename1 = c("Close Friend", "Distant Stranger") renames the levels in the first column of the summary table and renames the corresponding factor levels within the plot. (Note that the function applies the reposition argument to the summary table before applying the rename arguments.)

reorder1, reorder2, reorder3

String vectors to reorder the factor levels in the summary table and thus reorder factor levels within the plot itself. For example, reorder1 = c("Stranger", "Friend") reorders the levels in the first column of the summary table and reorders the corresponding factor levels within the plot. (Note that the function applies the reposition and rename arguments to the summary table before applying the reorder arguments.)

See Also

ggplot

Examples

## Line plot with 1 within-subjects factor
wrap.line(dv1 = bdata[c(6, 8)], ylim=c(0, 10), ymajor=2)

## Line plot with 1 within-subjects factor & 2 between-subjects factors
wrap.line(dv1 = bdata[c(6, 8)], iv1 = bdata$IV1, iv2 = bdata$IV2, ylim=c(0, 10), ymajor=2)


michaelkardas/bwrappers documentation built on Nov. 13, 2022, 1:14 a.m.