plot_design: Plot the generated stimuli's design

View source: R/plot_design.R

plot_designR Documentation

Plot the generated stimuli's design

Description

Takes the output from generate() or long_format(), and plots conditions' distributions on numeric variables used in the generate pipeline (i.e. indepdent variables, controls). Alternatively, distributions of any numeric variables in the original dataframe can be queried.

Usage

plot_design(
  df,
  include = "design",
  dodge_width = 0.1,
  point_size = 0.5,
  line_width = 1,
  force = TRUE,
  id_col = "string"
)

Arguments

df

Output from generate() or long_format()

include

A character vector indicating which variables to include in the plot. This can be those specified by split_by() and control_for() ("design"), only those specified in split_by() ("splits"), or only those specified by control_for() ("controls"). Alternatively, this can be a character vector of the variables that should be plotted, that were in the original dataframe. Default is "design".

dodge_width

The width to give to ggplot2::position_dodge (default is 0.2)

point_size

Size of points (default = 0.75)

line_width

Thickness of lines (default = 1)

force

Logical, should the function be forced to try and work if attributes are missing (default is TRUE)? If TRUE, will expect the dataframe to have a structure similar to that produced by long_format(), where condition is character or factor, and item_nr is numeric or factor. Other variables will be plot-able if given to the include argument.

id_col

A character vector specifying the column identifying unique observations (e.g. in LexOPS::lexops, the id_col is "string"). Ignored unless force=TRUE, in which case it is required.

Value

A ggplot object showing how conditions differ in independent variables, and are matched for in controls.

Examples


stim <- lexops |>
  dplyr::filter(PK.Brysbaert >= .75) |>
  split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |>
  split_by(CNC.Brysbaert, 1:2 ~ 4:5) |>
  control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |>
  control_for(Length) |>
  generate(n = 50, match_null = "balanced")
plot_design(stim)


JackEdTaylor/LexOPS documentation built on Oct. 11, 2024, 10:38 p.m.