control_for: Control for confounding variables.

View source: R/control_for.R

control_forR Documentation

Control for confounding variables.

Description

Specifies variables that should be controlled for in the generated stimuli, after splitting. Can be run multiple times to control for multiple variables.

Usage

control_for(x, var, tol = NA, standard_eval = FALSE)

Arguments

x

A data frame containing the IV and strings, or a LexOPS_pipeline object resulting from one of split_by(), control_for(), etc..

var

The column to treat as a control (non-standard evaluation).

tol

The tolerance of the control. For numeric variables, this should be in the form lower:upper (e.g. -0.1:0.1 will control within +/- 0.1). For categorical variables, this can be kept as NA.

standard_eval

Logical; bypasses non-standard evaluation, and allows more standard R objects in var and tol. If TRUE, var should be a character vector referring to a column in df (e.g. "Zipf.SUBTLEX_UK"), and tol should be a vector of length 2, specifying the tolerance (e.g. c(-0.1, 0.5)). Default = FALSE.

Value

Returns df, with details on the variables to be controlled for added to the attributes. Run the generate() function to then generate the actual stimuli.

Examples


# Create 3 levels of syllables, for 1-3, 4-6, and 7-20 syllables, and control for word frequency
lexops |>
  split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |>
  control_for(Zipf.SUBTLEX_UK, -0.2:0.2)

# Control for multiple variables
lexops |>
  split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |>
  control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |>
  control_for(PoS.SUBTLEX_UK)

# Bypass non-standard evaluation
lexops |>
 split_by("Syllables.CMU", list(c(1, 3), c(4, 6), c(7, 20)), standard_eval = TRUE) |>
 control_for("Zipf.SUBTLEX_UK", c(-0.2, 0.2), standard_eval = TRUE) |>
 control_for("PoS.SUBTLEX_UK", standard_eval = TRUE)


JackEdTaylor/LexOPS documentation built on July 10, 2024, 6:40 a.m.