View source: R/control_for_euc.R
control_for_euc | R Documentation |
This function is a wrapper for control_for_map
that allows you to easily control for Euclidean distance.
control_for_euc(
x,
vars,
tol,
name = NA,
scale = TRUE,
center = TRUE,
weights = NA,
standardise_weights = TRUE,
euc_df = NA,
standard_eval = FALSE
)
x |
A data frame containing the IV and strings, or a LexOPS_pipeline object resulting from one of |
vars |
The columns from which to calculate Euclidean distance. |
tol |
The desired control tolerance, in Euclidean distance (will be interpreted as scaled Euclidean distance if |
name |
What the output column should be named. If |
scale , center |
How should variables be scaled and/or centred before calculating Euclidean distance? For options, see the |
weights |
An (optional) list of weights, in the same order as |
standardise_weights |
Logical; should the weights be standardised to average to 1 (i.e., sum to the length of |
euc_df |
The dataframe to calculate the Euclidean distance from. By default, the function will use |
standard_eval |
Logical; bypasses non-standard evaluation, and allows more standard R objects in |
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.
stim <- lexops |>
split_by(CNC.Brysbaert, 1:2 ~ 4:5) |>
control_for_euc(c(Zipf.BNC.Written, Length), 0:0.005) |>
generate(10)
# bypass non-standard evaluation
stim <- lexops %>%
split_by(CNC.Brysbaert, 1:2 ~ 4:5) |>
control_for_euc(c("Zipf.BNC.Written", "Length"), c(0, 0.005), standard_eval = TRUE) |>
generate(10)
# generate stimuli from a filtered dataframe, but calculate
# Euclidean distance from an (original) unfiltered dataframe
library(dplyr)
stim <- lexops |>
filter(
Zipf.SUBTLEX_UK <= 5,
between(Length, 3, 12),
PK.Brysbaert >= 0.9
) |>
split_by(CNC.Brysbaert, 1:2 ~ 4:5) |>
control_for_euc(
c(Zipf.SUBTLEX_UK, Length),
0:0.005,
name = "Euclidean Distance",
euc_df = lexops
) |>
generate(10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.