split_by | R Documentation |
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)
x |
A data frame containing the IV and strings, or a LexOPS_pipeline object resulting from one of |
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 |
Returns df
, with a new column (name defined by cond_col
argument of set_options()
) identifying which level of the IV each string belongs to.
lexops
for the default data frame and associated variables.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.