| Title: | Selecting Matched Items for Factorial Designs |
|---|---|
| Description: | Select controlled items for factorial designs, matched with exact tolerances on any number of variables. Also supports (and can be combined with) matching on Euclidean distances and the outputs of functions. Full documentation is available at <https://jackedtaylor.github.io/LexOPSdocs/>. There is a 'shiny' app built with GUIs which supports most package functionality. The package is described by Taylor et al. (2020) <doi:10.3758/s13428-020-01389-1>. |
| Authors: | Jack Taylor [aut, cre] (ORCID: <https://orcid.org/0000-0003-4765-0118>), Alistair Beith [aut] (ORCID: <https://orcid.org/0000-0002-2260-4441>) |
| Maintainer: | Jack Taylor <[email protected]> |
| License: | GPL-3 |
| Version: | 0.6.4.9000 |
| Built: | 2026-12-02 09:41:37 UTC |
| Source: | https://github.com/jackedtaylor/lexops |
LexOPS_pipeline
Set an object's class to LexOPS_pipeline
as.LexOPS_pipeline(x)as.LexOPS_pipeline(x)
x |
Object, ultimately of class |
x, coerced into class LexOPS_pipeline
as.LexOPS_pipeline(lexops)as.LexOPS_pipeline(lexops)
Function for generating a visualisation for a box's selected options
box_vis( var, box_type = "primary", tol = NA, match_string = NA, shade_label = NA, shade_relative = TRUE, cat_vis = NA, df = lexopsdata::lexops )box_vis( var, box_type = "primary", tol = NA, match_string = NA, shade_label = NA, shade_relative = TRUE, cat_vis = NA, df = lexopsdata::lexops )
var |
Character vector specifying which variable is selected |
box_type |
Which type of box is it? (one of: "primary", "warning", "success", "danger", and "info") |
tol |
The area which should be highlighted. Can be a numeric vector of length two, a character vector of acceptable categories, or a list of such vectors. Each item in a |
match_string |
If the variable is being matched for, which string is it relative to. Leave as |
shade_label |
A character vector specifying what to label the levels. Order should match that of |
shade_relative |
If |
cat_vis |
which category should be highlighted (if a categorical variable)? Can be one of |
df |
A dataframe. Default is |
A ggplot2 or ggwordcloud object with the required visualisation.
Function for generating a visualisation of question marks surrounding a message
box_vis.question_marks(message, box_type)box_vis.question_marks(message, box_type)
message |
A string; the message to display. |
box_type |
The type of box the visualisation is presented in. |
A ggplot2 or ggwordcloud object with the required visualisation.
Get the measure name, source, and url for any vector of column names from lexops.
citation_table(cite_vars)citation_table(cite_vars)
cite_vars |
A character vector of column names |
A tibble that lists measures and sources of data that should be cited (if known).
citation_table(c("PK.Brysbaert", "HUM.Engelthaler"))citation_table(c("PK.Brysbaert", "HUM.Engelthaler"))
Takes the output from generate or long_format, and generates a tibble that lists known references that should be cited. This function will only be useful if you use variables from the lexops dataset (lexops) with their original names.
cite_design(df, include = "design")cite_design(df, include = "design")
df |
Output from |
include |
A string indicating which variables to include in the citation. This can be those specified by |
A tibble that lists measures and sources of data that should be cited (if known).
library(lexopsdata) stim <- lexops |> 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") cite_design(stim)library(lexopsdata) stim <- lexops |> 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") cite_design(stim)
Specifies variables that should be controlled for in the generated stimuli, after splitting. Can be run multiple times to control for multiple variables.
control_for(x, var, tol = NA, standard_eval = FALSE)control_for(x, var, tol = NA, standard_eval = FALSE)
x |
A data frame containing the IV and strings, or a |
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. |
standard_eval |
Logical; bypasses non-standard evaluation, and allows more standard R objects in |
A LexOPS_pipeline object, with details on the variables to be controlled for added to the attributes. Run the generate function to then generate the actual stimuli.
library(lexopsdata) # 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)library(lexopsdata) # 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)
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 )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 )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 )
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, ...)control_for_map(x, fun, var, tol = NA, name = NA, standard_eval = FALSE, ...)
x |
A data frame containing the IV and strings, or a |
fun |
The function to use to calculate the control variable. 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 |
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 values returned by the function fun. 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 only contain NAs.
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) # 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") # Use a function that returns a non-numeric output library(stringdist) stringdist_okay <- function(target, matches) { dist <- stringdist(target, matches, method="lv") ifelse(dist <= 4, "okay", "not_okay") } lexops |> split_by(AROU.Warriner, 1:3 ~ 7:9) |> control_for_map(stringdist_okay, string, "not_okay")library(lexopsdata) # 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") # Use a function that returns a non-numeric output library(stringdist) stringdist_okay <- function(target, matches) { dist <- stringdist(target, matches, method="lv") ifelse(dist <= 4, "okay", "not_okay") } lexops |> split_by(AROU.Warriner, 1:3 ~ 7:9) |> control_for_map(stringdist_okay, string, "not_okay")
Caclulates the Euclidean distance of a word from all other words in a df, on selected variables.
euc_dists( df = LexOPS::lexops, target, vars = "all", scale = TRUE, center = TRUE, weights = NA, standardise_weights = TRUE, id_col = "string", standard_eval = FALSE )euc_dists( df = LexOPS::lexops, target, vars = "all", scale = TRUE, center = TRUE, weights = NA, standardise_weights = TRUE, id_col = "string", standard_eval = FALSE )
df |
A data frame. |
target |
The target string (word) that euclidean distances are required for. |
vars |
The variables to be used as dimensions which Euclidean distance should be calculated over. Can be a vector of variable names (e.g. |
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 |
id_col |
The column containing the strings (default = |
standard_eval |
Logical; bypasses non-standard evaluation, and allows more standard R objects in |
A numeric vector of Euclidean distances, in the order of rows in df.
library(lexopsdata) # Get the distance of every entry in the `lexops` dataset from the word "thicket". # (Note: This will be calculated using the dimensions of frequency, arousal, and size) lexops |> euc_dists("thicket", c(Zipf.SUBTLEX_UK, AROU.Warriner, SIZE.Glasgow_Norms)) # no scaling or centering lexops |> euc_dists( "thicket", c(Zipf.SUBTLEX_UK, AROU.Warriner, SIZE.Glasgow_Norms), scale = FALSE, center = FALSE ) # Add Euclidean distance as new column # (Also sort ascendingly by distance; barbara will have a distance of 0 so will be first) lexops %>% dplyr::mutate(ed = euc_dists(., "barbara", c(Length, Zipf.SUBTLEX_UK, BG.SUBTLEX_UK))) |> dplyr::arrange(ed) # bypass non-standard evaluation lexops |> euc_dists( "thicket", c("Zipf.SUBTLEX_UK", "AROU.Warriner", "SIZE.Glasgow_Norms"), standard_eval = TRUE )library(lexopsdata) # Get the distance of every entry in the `lexops` dataset from the word "thicket". # (Note: This will be calculated using the dimensions of frequency, arousal, and size) lexops |> euc_dists("thicket", c(Zipf.SUBTLEX_UK, AROU.Warriner, SIZE.Glasgow_Norms)) # no scaling or centering lexops |> euc_dists( "thicket", c(Zipf.SUBTLEX_UK, AROU.Warriner, SIZE.Glasgow_Norms), scale = FALSE, center = FALSE ) # Add Euclidean distance as new column # (Also sort ascendingly by distance; barbara will have a distance of 0 so will be first) lexops %>% dplyr::mutate(ed = euc_dists(., "barbara", c(Length, Zipf.SUBTLEX_UK, BG.SUBTLEX_UK))) |> dplyr::arrange(ed) # bypass non-standard evaluation lexops |> euc_dists( "thicket", c("Zipf.SUBTLEX_UK", "AROU.Warriner", "SIZE.Glasgow_Norms"), standard_eval = TRUE )
Generates a text summary of a LexOPS_pipeline object resulting from one of split_by, control_for, etc..
## S3 method for class 'LexOPS_pipeline' format(x, ...)## S3 method for class 'LexOPS_pipeline' format(x, ...)
x |
A |
... |
Other arguments passed to or from other methods (unused). |
A character vector containing a formatted summary of the LexOPS pipeline.
library(lexopsdata) pipeline <- lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) format(pipeline)library(lexopsdata) pipeline <- lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) format(pipeline)
Generates the stimuli from the data frame after it has been passed through split_by, and optionally, control_for. Will generate n items per condition. If <n items can be generated, will generate as many as possible given the experiment's design.
generate( x, n = 20, match_null = "balanced", seed = NA, silent = FALSE, is_shiny = FALSE )generate( x, n = 20, match_null = "balanced", seed = NA, silent = FALSE, is_shiny = FALSE )
x |
A LexOPS_pipeline object resulting from one of |
n |
The number of strings per condition (default = 20). Set to |
match_null |
The condition that items should be matched to. Should be a string indicating condition (e.g. |
seed |
Deprecated: set seeds externally (e.g., |
silent |
Logical: should output to the console (via |
is_shiny |
Allows printing in a |
The generated stimuli, as a dataframe of class LexOPS_pipeline.
lexops for the data frame used in the examples.
library(lexopsdata) # Generate 10 words per condition, for design with 3 levels of syllables, controlled for frequency lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> generate(n = 10) # Generate 2 levels of bigram probability, controlling for frequency and length # (Note that the matching null is balanced across all stimuli) # (Also note that the data is filtered by proportion known to be >75%) lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length) |> generate(n = 10, match_null = "balanced") # Generate stimuli for a concreteness x valence (2 x 3) design # (Note that abstract, neutral is set as the matching null) lexops |> split_by(CNC.Brysbaert, 1:2 ~ 4:5) |> split_by(VAL.Warriner, 1:3 ~ 4.5:5.5 ~ 7:9) |> control_for(Zipf.SUBTLEX_UK, -0.25:0.25) |> control_for(Length) |> generate(n = 10, match_null = "A2_B2") # As above but with inclusive tolerance # (all words are within the specified tolerances relative to each other) lexops |> split_by(CNC.Brysbaert, 1:2 ~ 4:5) |> split_by(VAL.Warriner, 1:3 ~ 4.5:5.5 ~ 7:9) |> control_for(Zipf.SUBTLEX_UK, -0.25:0.25) |> control_for(Length) |> generate(n = 10, match_null = "inclusive") # 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) |> generate(n = 10) # Create two levels of arousal, controlling for orthographic Levenshtein distance library(stringdist) lexops |> split_by(AROU.Warriner, 1:3 ~ 6:9) |> control_for_map(stringdist, string, 0:4, method="lv") |> generate(10) # Create two levels of arousal, controlling for phonological similarity library(stringdist) lexops |> split_by(AROU.Warriner, 1:3 ~ 6:9) |> control_for_map(stringdist, eSpeak.br_1letter, 0:2, method="lv") |> generate(10) # Create two levels of arousal, controlling for phonological Levenshtein distance, and rhyme library(stringdist) lexops |> split_by(AROU.Warriner, 1:3 ~ 6:9) |> control_for(Rhyme.eSpeak.br) |> control_for_map(stringdist, eSpeak.br_1letter, 0:2, method="lv") |> generate(10) # A similar design to that above, but with 3 levels of valence, and inclusive matching library(stringdist) lexops |> split_by(VAL.Warriner, 1:3 ~ 4.5:5.5 ~ 7:9) |> control_for(Rhyme.eSpeak.br) |> control_for_map(stringdist, eSpeak.br_1letter, 0:2, method="lv") |> generate(10, match_null = "inclusive")library(lexopsdata) # Generate 10 words per condition, for design with 3 levels of syllables, controlled for frequency lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> generate(n = 10) # Generate 2 levels of bigram probability, controlling for frequency and length # (Note that the matching null is balanced across all stimuli) # (Also note that the data is filtered by proportion known to be >75%) lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length) |> generate(n = 10, match_null = "balanced") # Generate stimuli for a concreteness x valence (2 x 3) design # (Note that abstract, neutral is set as the matching null) lexops |> split_by(CNC.Brysbaert, 1:2 ~ 4:5) |> split_by(VAL.Warriner, 1:3 ~ 4.5:5.5 ~ 7:9) |> control_for(Zipf.SUBTLEX_UK, -0.25:0.25) |> control_for(Length) |> generate(n = 10, match_null = "A2_B2") # As above but with inclusive tolerance # (all words are within the specified tolerances relative to each other) lexops |> split_by(CNC.Brysbaert, 1:2 ~ 4:5) |> split_by(VAL.Warriner, 1:3 ~ 4.5:5.5 ~ 7:9) |> control_for(Zipf.SUBTLEX_UK, -0.25:0.25) |> control_for(Length) |> generate(n = 10, match_null = "inclusive") # 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) |> generate(n = 10) # Create two levels of arousal, controlling for orthographic Levenshtein distance library(stringdist) lexops |> split_by(AROU.Warriner, 1:3 ~ 6:9) |> control_for_map(stringdist, string, 0:4, method="lv") |> generate(10) # Create two levels of arousal, controlling for phonological similarity library(stringdist) lexops |> split_by(AROU.Warriner, 1:3 ~ 6:9) |> control_for_map(stringdist, eSpeak.br_1letter, 0:2, method="lv") |> generate(10) # Create two levels of arousal, controlling for phonological Levenshtein distance, and rhyme library(stringdist) lexops |> split_by(AROU.Warriner, 1:3 ~ 6:9) |> control_for(Rhyme.eSpeak.br) |> control_for_map(stringdist, eSpeak.br_1letter, 0:2, method="lv") |> generate(10) # A similar design to that above, but with 3 levels of valence, and inclusive matching library(stringdist) lexops |> split_by(VAL.Warriner, 1:3 ~ 4.5:5.5 ~ 7:9) |> control_for(Rhyme.eSpeak.br) |> control_for_map(stringdist, eSpeak.br_1letter, 0:2, method="lv") |> generate(10, match_null = "inclusive")
Simple function for getting the visualisation colour (in hex) for different coloured boxes. Colours are only accurate for the LexOPS shiny app.
get_box_colour(box_type)get_box_colour(box_type)
box_type |
A character vector (one of: "primary", "warning", "Success", "danger", and "info"), specifying which kind of box to generate the colour for. |
A character vector of the colour's hex value.
LexOPS_pipeline
Check whether an object is of class LexOPS_pipeline
is.LexOPS_pipeline(x)is.LexOPS_pipeline(x)
x |
Object, possibly resulting from one of |
A logical value: TRUE if x is of class LexOPS_pipeline, or FALSE otherwise.
library(lexopsdata) # the lexops dataset is not a LexOPS_pipeline before going through split_by() or control_for() is.LexOPS_pipeline(lexops) # FALSE # a pipeline pregeneration is a LexOPS_pipeline pregen <- lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) is.LexOPS_pipeline(pregen) # TRUE # a pipeline's output is still a LexOPS_pipeline after going through generate() postgen <- generate(pregen, 10) is.LexOPS_pipeline(postgen) # TRUElibrary(lexopsdata) # the lexops dataset is not a LexOPS_pipeline before going through split_by() or control_for() is.LexOPS_pipeline(lexops) # FALSE # a pipeline pregeneration is a LexOPS_pipeline pregen <- lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) is.LexOPS_pipeline(pregen) # TRUE # a pipeline's output is still a LexOPS_pipeline after going through generate() postgen <- generate(pregen, 10) is.LexOPS_pipeline(postgen) # TRUE
A data frame containing 68 variables for words, in English. This dataset was originally stored in the LexOPS package, but is now installed separately via lexopsdata (lexops).
lexopslexops
The data.frame object containing the lexops dataset.
lexopslexops
Converts the generated stimuli from the generate function into long format.
long_format(df, include = "design", include_candids = FALSE)long_format(df, include = "design", include_candids = FALSE)
df |
A data frame that is the result from |
include |
A string indicating whether the long-format result should include all variables in the original data frame ( |
include_candids |
Logical; whether to include data about unused candidates in the result. If |
The generated stimuli, as a data.frame object in long format, containing requested variables from the original df, and the variables of item_nr, condition, euclidean_distance (from the match_null).
library(lexopsdata) lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> generate(n = 20) |> long_format(include = "all")library(lexopsdata) lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> generate(n = 20) |> long_format(include = "all")
Suggests items that are suitable matches for a target item, based on selected variables of a data frame. Note that unlike functions in the generate pipeline (e.g. control_for), multiple variables' tolerances can be defined in one function.
match_item( df = LexOPS::lexops, target, ..., id_col = "string", filter = TRUE, standard_eval = FALSE )match_item( df = LexOPS::lexops, target, ..., id_col = "string", filter = TRUE, standard_eval = FALSE )
df |
A data frame to reorder, containing the target string (default = |
target |
The target string |
... |
Should specify the variables and tolerances in the form |
id_col |
A character vector specifying the column identifying unique observations (e.g. in |
filter |
Logical. If TRUE, matches outside the tolerances specified in vars are removed. If FALSE, a new column, matchFilter is calculated indicating whether or not the string is within all variables' tolerances. (Default = TRUE.) |
standard_eval |
Logical; bypasses non-standard evaluation, and allows more standard R object of list. If |
An object of class data.frame derived from df. If filter == TRUE, will only contain matches. If filter == FALSE, will be the original df object, with a new column, "matchFilter".
lexops for the default data frame and associated variables.
library(lexopsdata) # Match by number of syllables exactly match_item(lexops, "thicket", Syllables.CMU) # Match by number of syllables exactly, but keep all entries in the original dataframe match_item(lexops, "thicket", Syllables.CMU, filter = FALSE) # Match by number of syllables exactly, and rhyme match_item(lexops, "thicket", Syllables.CMU, Rhyme.CMU) # Match by length exactly, and closely by frequency (within 0.2 Zipf either way) match_item(lexops, "thicket", Length, Zipf.SUBTLEX_UK = -0.2:0.2) # The syntax supports matching by multiple variables match_item( lexops, "elephant", BG.SUBTLEX_UK = -0.005:0.005, Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK, RT.ELP = -10:10 ) # Match using standard evaluation match_item( lexops, "thicket", list("Length", c("Zipf.SUBTLEX_UK", -0.2, 0.2)), standard_eval = TRUE ) # Find matches within an orthographic levenshtein distance of 5 from "thicket": library(dplyr) library(stringdist) targ_word <- "thicket" lexops |> mutate(old = stringdist(targ_word, string, method="lv")) |> match_item(targ_word, old = 0:5) # Find matches within a phonological levenshtein distance of 2 from "thicket": # (note that this method requires 1-letter phonological transcriptions) library(dplyr) library(stringdist) targ_word <- "thicket" targ_word_pronun <- lexops |> filter(string == "thicket") |> pull(eSpeak.br_1letter) lexops |> mutate(pld = stringdist(targ_word_pronun, eSpeak.br_1letter, method="lv")) |> match_item(targ_word, pld = 0:2)library(lexopsdata) # Match by number of syllables exactly match_item(lexops, "thicket", Syllables.CMU) # Match by number of syllables exactly, but keep all entries in the original dataframe match_item(lexops, "thicket", Syllables.CMU, filter = FALSE) # Match by number of syllables exactly, and rhyme match_item(lexops, "thicket", Syllables.CMU, Rhyme.CMU) # Match by length exactly, and closely by frequency (within 0.2 Zipf either way) match_item(lexops, "thicket", Length, Zipf.SUBTLEX_UK = -0.2:0.2) # The syntax supports matching by multiple variables match_item( lexops, "elephant", BG.SUBTLEX_UK = -0.005:0.005, Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK, RT.ELP = -10:10 ) # Match using standard evaluation match_item( lexops, "thicket", list("Length", c("Zipf.SUBTLEX_UK", -0.2, 0.2)), standard_eval = TRUE ) # Find matches within an orthographic levenshtein distance of 5 from "thicket": library(dplyr) library(stringdist) targ_word <- "thicket" lexops |> mutate(old = stringdist(targ_word, string, method="lv")) |> match_item(targ_word, old = 0:5) # Find matches within a phonological levenshtein distance of 2 from "thicket": # (note that this method requires 1-letter phonological transcriptions) library(dplyr) library(stringdist) targ_word <- "thicket" targ_word_pronun <- lexops |> filter(string == "thicket") |> pull(eSpeak.br_1letter) lexops |> mutate(pld = stringdist(targ_word_pronun, eSpeak.br_1letter, method="lv")) |> match_item(targ_word, pld = 0:2)
match_item
The match_word() function has been replaced by match_item. This wrapper for the function has been kept to support backwards compatibility to code written in older versions of LexOPS. This wrapper may be removed in the future, so please update your code to use match_item.
match_word( df = LexOPS::lexops, target, ..., id_col = "string", filter = TRUE, standard_eval = FALSE )match_word( df = LexOPS::lexops, target, ..., id_col = "string", filter = TRUE, standard_eval = FALSE )
df |
A data frame to reorder, containing the target string (default = |
target |
The target string |
... |
Should specify the variables and tolerances in the form |
id_col |
A character vector specifying the column identifying unique observations (e.g. in |
filter |
Logical. If TRUE, matches outside the tolerances specified in vars are removed. If FALSE, a new column, matchFilter is calculated indicating whether or not the string is within all variables' tolerances. (Default = TRUE.) |
standard_eval |
Logical; bypasses non-standard evaluation, and allows more standard R object of list. If |
An object of class data.frame derived from df. If filter == TRUE, will only contain matches. If filter == FALSE, will be the original df object, with a new column, "matchFilter".
lexops for the default data frame and associated variables.
library(lexopsdata) # Match by number of syllables exactly match_word(lexops, "thicket", Syllables.CMU) # Match by number of syllables exactly, but keep all entries in the original dataframe match_word(lexops, "thicket", Syllables.CMU, filter = FALSE) # Match by number of syllables exactly, and rhyme match_word(lexops, "thicket", Syllables.CMU, Rhyme.CMU) # Match by length exactly, and closely by frequency (within 0.2 Zipf either way) match_word(lexops, "thicket", Length, Zipf.SUBTLEX_UK = -0.2:0.2) # The syntax supports matching by multiple variables match_word( lexops, "elephant", BG.SUBTLEX_UK = -0.005:0.005, Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK, RT.ELP = -10:10 ) # Match using standard evaluation match_word( lexops, "thicket", list("Length", c("Zipf.SUBTLEX_UK", -0.2, 0.2)), standard_eval = TRUE ) # Find matches within an orthographic levenshtein distance of 5 from "thicket": library(dplyr) library(stringdist) targ_word <- "thicket" lexops |> mutate(old = stringdist(targ_word, string, method="lv")) |> match_word(targ_word, old = 0:5) # Find matches within a phonological levenshtein distance of 2 from "thicket": # (note that this method requires 1-letter phonological transcriptions) library(dplyr) library(stringdist) targ_word <- "thicket" targ_word_pronun <- lexops |> filter(string == "thicket") |> pull(eSpeak.br_1letter) lexops |> mutate(pld = stringdist(targ_word_pronun, eSpeak.br_1letter, method="lv")) |> match_word(targ_word, pld = 0:2)library(lexopsdata) # Match by number of syllables exactly match_word(lexops, "thicket", Syllables.CMU) # Match by number of syllables exactly, but keep all entries in the original dataframe match_word(lexops, "thicket", Syllables.CMU, filter = FALSE) # Match by number of syllables exactly, and rhyme match_word(lexops, "thicket", Syllables.CMU, Rhyme.CMU) # Match by length exactly, and closely by frequency (within 0.2 Zipf either way) match_word(lexops, "thicket", Length, Zipf.SUBTLEX_UK = -0.2:0.2) # The syntax supports matching by multiple variables match_word( lexops, "elephant", BG.SUBTLEX_UK = -0.005:0.005, Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK, RT.ELP = -10:10 ) # Match using standard evaluation match_word( lexops, "thicket", list("Length", c("Zipf.SUBTLEX_UK", -0.2, 0.2)), standard_eval = TRUE ) # Find matches within an orthographic levenshtein distance of 5 from "thicket": library(dplyr) library(stringdist) targ_word <- "thicket" lexops |> mutate(old = stringdist(targ_word, string, method="lv")) |> match_word(targ_word, old = 0:5) # Find matches within a phonological levenshtein distance of 2 from "thicket": # (note that this method requires 1-letter phonological transcriptions) library(dplyr) library(stringdist) targ_word <- "thicket" targ_word_pronun <- lexops |> filter(string == "thicket") |> pull(eSpeak.br_1letter) lexops |> mutate(pld = stringdist(targ_word_pronun, eSpeak.br_1letter, method="lv")) |> match_word(targ_word, pld = 0:2)
This is useful for specifying multiple parameters in non-standard evaluation for match_item().
parse_ellipsis(...)parse_ellipsis(...)
... |
Variables and tolerances, in the form |
A list object in the form list(c("num_variable1", -1, 3), c("num_variable2", -0.5, 0.5), "char_variable1").
parse_ellipsis(substitute(c(Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK))) parse_ellipsis(substitute(c(Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK, BG.SUBTLEX_UK = -0.005:0.005)))parse_ellipsis(substitute(c(Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK))) parse_ellipsis(substitute(c(Length = 0:0, Zipf.SUBTLEX_UK = -0.1:0.1, PoS.SUBTLEX_UK, BG.SUBTLEX_UK = -0.005:0.005)))
split_by())A non-standard evaluation parser for levels (e.g., for split_by())
parse_levels(var, levels = NA)parse_levels(var, levels = NA)
var |
A column name (non-standard evaluation). |
levels |
Levels in the form of tilde-separated vectors (e.g. |
A list object in the form list("column_name", c(1, 2), c(3, 4), c(5, 6)).
# Numeric sections of a distribution can be specified as lower:upper bound... parse_levels(substitute(Zipf.SUBTLEX_UK), substitute(1:2 ~ 3:4 ~ 5:6)) # ...or c(lower, upper) parse_levels(substitute(Zipf.SUBTLEX_UK), substitute(c(1, 2) ~ c(3, 4) ~ c(5, 6))) # Can give any level as just `NULL` or `NA` to store the level as `NA` # (e.g. for `split_by_map()` function in future) parse_levels(substitute(example_variable), substitute(NULL ~ 1.2:4 ~ 5.2:6)) parse_levels(substitute(example_variable), substitute(NA ~ 1.2:4 ~ 5.2:6)) # Non-numeric categories can be specified like so parse_levels(substitute(PoS.SUBTLEX_UK), substitute("noun" ~ "verb")) parse_levels(substitute(PoS.SUBTLEX_UK), substitute(c("noun", "name") ~ c("adjective", "verb"))) # Can give no value for `levels` (i.e. `levels` is `NA`), # e.g. when matching exactly, or categorically parse_levels(substitute(PoS.SUBTLEX_UK)) # Can give vector of variables in non-standard eval parse_levels(substitute(c(Zipf.SUBTLEX_UK, Length)), substitute(0:2.5)) parse_levels(substitute(c(Zipf.SUBTLEX_UK, Length)))# Numeric sections of a distribution can be specified as lower:upper bound... parse_levels(substitute(Zipf.SUBTLEX_UK), substitute(1:2 ~ 3:4 ~ 5:6)) # ...or c(lower, upper) parse_levels(substitute(Zipf.SUBTLEX_UK), substitute(c(1, 2) ~ c(3, 4) ~ c(5, 6))) # Can give any level as just `NULL` or `NA` to store the level as `NA` # (e.g. for `split_by_map()` function in future) parse_levels(substitute(example_variable), substitute(NULL ~ 1.2:4 ~ 5.2:6)) parse_levels(substitute(example_variable), substitute(NA ~ 1.2:4 ~ 5.2:6)) # Non-numeric categories can be specified like so parse_levels(substitute(PoS.SUBTLEX_UK), substitute("noun" ~ "verb")) parse_levels(substitute(PoS.SUBTLEX_UK), substitute(c("noun", "name") ~ c("adjective", "verb"))) # Can give no value for `levels` (i.e. `levels` is `NA`), # e.g. when matching exactly, or categorically parse_levels(substitute(PoS.SUBTLEX_UK)) # Can give vector of variables in non-standard eval parse_levels(substitute(c(Zipf.SUBTLEX_UK, Length)), substitute(0:2.5)) parse_levels(substitute(c(Zipf.SUBTLEX_UK, Length)))
c() in a character vector representation.A parse for extracting contents of c() in a character vector representation.
parse_unvectorise(vec_str)parse_unvectorise(vec_str)
vec_str |
The character vector (string), e.g., |
A parsed, unvectorised character vector.
Takes the output from generate or long_format, and plots conditions' distributions on numeric variables used in the generate pipeline (i.e. indepdent variables, controls). Alternatively, distributions of any numeric variables in the original dataframe can be queried.
plot_design( df, include = "design", dodge_width = 0.1, point_size = 0.5, line_width = 1, force = TRUE, id_col = "string" )plot_design( df, include = "design", dodge_width = 0.1, point_size = 0.5, line_width = 1, force = TRUE, id_col = "string" )
df |
Output from |
include |
A character vector indicating which variables to include in the plot. This can be those specified by |
dodge_width |
The width to give to |
point_size |
Size of points (default = 0.75) |
line_width |
Thickness of lines (default = 1) |
force |
Logical, should the function be forced to try and work if attributes are missing (default is |
id_col |
A character vector specifying the column identifying unique observations (e.g. in |
A ggplot2 object visualising how conditions differ in independent variables, and are matched for in controls.
library(lexopsdata) 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_design(stim)library(lexopsdata) 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_design(stim)
Plots iterations by number of items generated, when given a dataframe which has been passed through generate.
plot_iterations(df, line_width = 1)plot_iterations(df, line_width = 1)
df |
Output from |
line_width |
Thickness of lines (default = 1) |
A ggplot2 object visualising how conditions differ in independent variables, and are matched for in controls.
library(lexopsdata) 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_iterations(stim)library(lexopsdata) 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_iterations(stim)
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.
plot_sample(df, include = "design", force = TRUE, id_col = "string")plot_sample(df, include = "design", force = TRUE, id_col = "string")
df |
Output from |
include |
A character vector indicating which variables to include in the plot. This can be those specified by |
force |
Logical, should the function be forced to try and work if attributes are missing (default is |
id_col |
A character vector specifying the column identifying unique observations (e.g. in |
A ggplot2 object showing how conditions differ in independent variables, and are matched for in controls.
library(lexopsdata) stim <- lexops |> dplyr::filter(PK.Brysbaert >= .75) |> split_by(PoS.SUBTLEX_UK, "noun" ~ "adjective" ~ "verb") |> split_by(CNC.Brysbaert, 1:2 ~ 4:5) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) |> generate(n = 50, match_null = "balanced") plot_sample(stim)library(lexopsdata) stim <- lexops |> dplyr::filter(PK.Brysbaert >= .75) |> split_by(PoS.SUBTLEX_UK, "noun" ~ "adjective" ~ "verb") |> split_by(CNC.Brysbaert, 1:2 ~ 4:5) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) |> generate(n = 50, match_null = "balanced") plot_sample(stim)
Copied from old versions of rlang as function now deprecated.
prepend(x, values, before = 1)prepend(x, values, before = 1)
x |
the vector to be modified. |
values |
to be included in the modified vector. |
before |
a subscript, before which the values are to be appended. |
A merged vector.
A prepend function that plays nicely with lists.
prepend_list(x, ...)prepend_list(x, ...)
x |
the vector to be modified. |
... |
the objects to be included in the modified vector. |
A merged vector.
Prints a summary about a LexOPS pipeline object (returned from functions like split_by, control_for, etc.), listing the splits and controls in the pipeline so far.
## S3 method for class 'LexOPS_pipeline' print(x, ...)## S3 method for class 'LexOPS_pipeline' print(x, ...)
x |
A |
... |
Other arguments passed to or from other methods (unused). |
No return value, called for side effects (printing).
library(lexopsdata) pipeline <- lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) pipelinelibrary(lexopsdata) pipeline <- lexops |> subset(PK.Brysbaert >= .75) |> split_by(BG.SUBTLEX_UK, 0.001:0.003 ~ 0.009:0.011) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> control_for(Length, 0:0) pipeline
shiny AppRuns the LexOPS shiny App, with optional additional arguments.
run_shiny(...)run_shiny(...)
... |
optional arguments to |
The LexOPS shiny app requires additional packages. If any dependencies are missing, the user will be prompted to install them. The additional packages required are:
shiny
shinydashboard
plotly
ggwordcloud
colourpicker
shinycssloaders
shinyjs
viridis
DT
readr
forcats
stringdist
lexopsdata (http://github.com/JackEdTaylor/lexopsdata)
No return value, called to initialise the LexOPS shiny app.
if (interactive()) { run_shiny() }if (interactive()) { run_shiny() }
Function for converting a numeric vector into recommended arguments for shiny::sliderInput, for sliders in LexOPS.
sensible_slider_vals(numeric_vec, n_levels, is_tolerance = FALSE)sensible_slider_vals(numeric_vec, n_levels, is_tolerance = FALSE)
numeric_vec |
The numeric vector which the slider will be for. |
n_levels |
How many sliders are to be generated for this variable? |
is_tolerance |
Logical; is the slider for specifying tolerances (e.g. for matching)? Default is |
A list object, containing the following recommended argument values for shiny::sliderInput:
min
max
value
step
When the first function called in a generate pipeline, allows the user to set options that will be passed to all subsequent functions in the pipeline.
set_options(df, id_col = "string", cond_col = "LexOPS_splitCond")set_options(df, id_col = "string", cond_col = "LexOPS_splitCond")
df |
The dataframe that will be used in the generate pipeline. |
id_col |
A character vector specifying the column identifying unique observations (e.g. in |
cond_col |
Prefix with which to name the columns where conditions will be stored (default = "LexOPS_splitCond"). Each time |
An object of class LexOPS_pipeline, containing dataframe df, with the options stored in the attributes.
library(lexopsdata) # give a df with "word" as the identifying column lexops |> dplyr::rename(word = string) |> # tell LexOPS that "word" is the identifying column set_options(id_col = "word") |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> generate(n = 20)library(lexopsdata) # give a df with "word" as the identifying column lexops |> dplyr::rename(word = string) |> # tell LexOPS that "word" is the identifying column set_options(id_col = "word") |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> control_for(Zipf.SUBTLEX_UK, -0.2:0.2) |> generate(n = 20)
Specifies splits for one IV for a factorial design. Can be called multiple times for multiple splits.
split_by(x, var, levels, filter = TRUE, standard_eval = FALSE)split_by(x, var, levels, filter = TRUE, standard_eval = FALSE)
x |
A data frame containing the IV and strings, or a |
var |
The column to treat as an independent variable (non-standard evaluation). |
levels |
The boundaries to use as levels of this variable (non-standard evaluation). These should be specified in the form |
filter |
Logical. If TRUE, words which fit no conditions are removed. |
standard_eval |
Logical; bypasses non-standard evaluation, and allows more standard R objects in |
A LexOPS_pipeline object, where df has a new column (name defined by cond_col argument of set_options()) identifying which level of the IV each item belongs to.
lexops for the default data frame and associated variables.
library(lexopsdata) # Create 3 levels of syllables, for 1-3, 4-6, and 7-20 syllables lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) # Same split as above, but supplying boundaries as vectors lexops |> split_by(Syllables.CMU, c(1, 3) ~ c(4, 6) ~ c(7, 20)) # Create 2 levels of position of speech, noun and verb lexops |> split_by(PoS.SUBTLEX_UK, "noun" ~ "verb") # split into two levels: (1) nouns or names, and (2) adjectives or adverbs lexops |> split_by(PoS.SUBTLEX_UK, c("noun", "name") ~ c("adjective", "adverb")) # Perform two splits lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> split_by(PoS.SUBTLEX_UK, c("noun", "name") ~ c("adjective", "adverb")) # Bypass non-standard evaluation lexops |> split_by("Syllables.CMU", list(c(1, 3), c(4, 6), c(7, 20)), standard_eval = TRUE) |> split_by("PoS.SUBTLEX_UK", list(c("noun", "name"), "verb"), standard_eval = TRUE)library(lexopsdata) # Create 3 levels of syllables, for 1-3, 4-6, and 7-20 syllables lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) # Same split as above, but supplying boundaries as vectors lexops |> split_by(Syllables.CMU, c(1, 3) ~ c(4, 6) ~ c(7, 20)) # Create 2 levels of position of speech, noun and verb lexops |> split_by(PoS.SUBTLEX_UK, "noun" ~ "verb") # split into two levels: (1) nouns or names, and (2) adjectives or adverbs lexops |> split_by(PoS.SUBTLEX_UK, c("noun", "name") ~ c("adjective", "adverb")) # Perform two splits lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6 ~ 7:20) |> split_by(PoS.SUBTLEX_UK, c("noun", "name") ~ c("adjective", "adverb")) # Bypass non-standard evaluation lexops |> split_by("Syllables.CMU", list(c(1, 3), c(4, 6), c(7, 20)), standard_eval = TRUE) |> split_by("PoS.SUBTLEX_UK", list(c("noun", "name"), "verb"), standard_eval = TRUE)
Adds a split to the data comparable to that made by split_by, but split randomly through the data. All entries in df of the resulting LexOPS_pipeline object are assigned a level randomly.
split_random(x, nlevels = 2, seed = NA, equal_size = FALSE)split_random(x, nlevels = 2, seed = NA, equal_size = FALSE)
x |
A data frame containing the IV and strings, or a LexOPS_pipeline object resulting from one of |
nlevels |
An integer, specifying how many levels this random split should have (default = 2). |
seed |
Deprecated: set seeds externally instead (e.g., |
equal_size |
Logical; should LexOPS create equal (or as close to equal as possible) numbers of candidates for each level? When |
A LexOPS_pipeline object, where df has a new column (name defined by cond_col argument) identifying which level of the randomly generated IV each item belongs to.
library(lexopsdata) # 2 (syllables: few, many) by 2 (random: level 1, level 2) design lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6) |> split_random(nlevels = 2, equal_size = TRUE)library(lexopsdata) # 2 (syllables: few, many) by 2 (random: level 1, level 2) design lexops |> split_by(Syllables.CMU, 1:3 ~ 4:6) |> split_random(nlevels = 2, equal_size = TRUE)
Converts the name of a variable from lexops (e.g. "fpmw.SUBTLEX_US") into the name of its measure (e.g. "frequency per million words").
var_to_measure( var, first_cite = TRUE, default = "", title_caps = FALSE, include_pronunciations = TRUE, standard_eval = FALSE )var_to_measure( var, first_cite = TRUE, default = "", title_caps = FALSE, include_pronunciations = TRUE, standard_eval = FALSE )
var |
The variable name (non-standard evaluation) |
first_cite |
Logical; if |
default |
The character string that should be returned if the variable does not have a known cietable source |
title_caps |
Logical; use title capitalisation (e.g. "Familiarity Ratings" rather than "famliarity ratings"). Default is |
include_pronunciations |
Logical; allow pronunciation transpositions as measures (e.g. CMU.1letter). Default is |
standard_eval |
Logical; bypasses non-standard evaluation. If |
A citation of a variable's source in APA format. Returns default if not recognised as a citeabile source.
var_to_measure(Zipf.SUBTLEX_UK) var_to_measure("AROU.Glasgow_Norms", standard_eval = TRUE) var_to_measure(AoA.Kuperman, first_cite = FALSE)var_to_measure(Zipf.SUBTLEX_UK) var_to_measure("AROU.Glasgow_Norms", standard_eval = TRUE) var_to_measure(AoA.Kuperman, first_cite = FALSE)
Converts the name of a variable from lexops (e.g. "Zipf.SUBTLEX_US") into an APA-style citation (e.g. "SUBTLEX-US (Brysbaert & New, 2009)").
var_to_source(var, first_cite = TRUE, default = "", standard_eval = FALSE)var_to_source(var, first_cite = TRUE, default = "", standard_eval = FALSE)
var |
The variable name (non-standard evaluation) |
first_cite |
Logical; if |
default |
The character string that should be returned if the variable does not have a known citeable source |
standard_eval |
Logical; bypasses non-standard evaluation. If |
A citation of a variable's source in APA format. Returns default if not recognised as a citeable source.
var_to_source(Zipf.SUBTLEX_UK) var_to_source("AROU.Glasgow_Norms", standard_eval = TRUE) var_to_source(AoA.Kuperman, first_cite = FALSE)var_to_source(Zipf.SUBTLEX_UK) var_to_source("AROU.Glasgow_Norms", standard_eval = TRUE) var_to_source(AoA.Kuperman, first_cite = FALSE)
Converts the name of a variable from lexops (e.g. "Zipf.SUBTLEX_US") into a url (usually doi).
var_to_url(var, default = "", standard_eval = FALSE)var_to_url(var, default = "", standard_eval = FALSE)
var |
The variable name (non-standard evaluation) |
default |
The character string that should be returned if the variable does not have a known citeable source |
standard_eval |
Logical; bypasses non-standard evaluation. If |
A citation of a variable's source in APA format. Returns default if not recognised as a citeabile source.
var_to_url(Zipf.SUBTLEX_UK) var_to_url("AROU.Glasgow_Norms", standard_eval = TRUE) var_to_url(AoA.Kuperman)var_to_url(Zipf.SUBTLEX_UK) var_to_url("AROU.Glasgow_Norms", standard_eval = TRUE) var_to_url(AoA.Kuperman)