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 |
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 |
The long format version of the generated items (long_format) will include a column, with the name defined by the name argument. This will include the calculated Euclidean distances. If the match null is set in generate to be inclusive (match_null="inclusive") and there are more than two factorial cells, this column will contain the maximum of all Euclidean distances for a given item.
A LexOPS_pipeline object, where df has details on the variables to be controlled for added to the attributes. Run the generate function to then generate the actual stimuli.
library(lexopsdata)
stim <- lexops |>
split_by(CNC.Brysbaert, 1:2 ~ 4:5) |>
control_for_euc(c(Zipf.BNC.Written, Length), 0:0.005)
# 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 stimuli from a subsetted dataframe, but calculate
# Euclidean distance from an (original) unsubsetted dataframe
stim <- lexops |>
subset(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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.