plot_sample: Plot how well the stimuli represent the underlying population...

View source: R/plot_sample.R

plot_sampleR Documentation

Plot how well the stimuli represent the underlying population of words given

Description

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

Usage

plot_sample(df, include = "design", 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".

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_sample(stim)


JackEdTaylor/LexOPS documentation built on Sept. 10, 2023, 3:09 a.m.