View source: R/control_for_map.R
control_for_map | R Documentation |
Some variables (e.g. similarity measures) are hard to control for with control_for
as they need to be recalculated for each word relative to each other, rather than there being a single value for each possible stimulus. The control_for_map
function declares a function that the generate
function should apply to each match_null within an iteration of stimulus generation. The function given as fun
should be able to take the data in the column given in var
as the first argument, and should be able to take the match_null's value in that column as the second argument.
control_for_map(x, fun, var, tol = NA, name = NA, standard_eval = FALSE, ...)
x |
A data frame containing the IV and strings, or a LexOPS_pipeline object resulting from one of |
fun |
The function to use to calculate the control varibale. Should be an object of class "function". |
var |
The column to provide the value which will be the first argument of the function. |
tol |
The tolerance of the control. For numeric variables, this should be in the form lower:upper (e.g. |
name |
What the output column should be named. If |
standard_eval |
Logical; bypasses non-standard evaluation, and allows more standard R objects in |
... |
Arguments to be passed to |
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.
# Create two levels of arousal, controlling for orthographic similarity
# (as optimal string alignment; default for `stringdist()`)
library(stringdist)
lexops |>
split_by(AROU.Warriner, 1:3 ~ 7:9) |>
control_for_map(stringdist, string, 0:4)
# Create two levels of arousal, controlling for orthographic Levenshtein distance
# (passed via `method` argument to `stringdist()`)
library(stringdist)
lexops |>
split_by(AROU.Warriner, 1:3 ~ 7:9) |>
control_for_map(stringdist, string, 0:4, method="lv")
# Create two levels of arousal, controlling for phonological Levenshtein distance
library(stringdist)
lexops |>
split_by(AROU.Warriner, 1:3 ~ 7:9) |>
control_for_map(stringdist, eSpeak.br_1letter, 0:2, method="lv")
# Bypass non-standard evaluation
library(stringdist)
lexops |>
split_by(AROU.Warriner, 1:3 ~ 7:9) |>
control_for_map(stringdist, "eSpeak.br_1letter", c(0, 2), standard_eval=TRUE, method="lv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.