View source: R/tidy_add_term_labels.R
tidy_add_term_labels | R Documentation |
Will add term labels in a label
column, based on:
labels provided in labels
argument if provided;
factor levels for categorical variables coded with
treatment, SAS or sum contrasts (the label could be
customized with categorical_terms_pattern
argument);
variable labels when there is only one term per variable;
term name otherwise.
tidy_add_term_labels(
x,
labels = NULL,
interaction_sep = " * ",
categorical_terms_pattern = "{level}",
model = tidy_get_model(x),
quiet = FALSE,
strict = FALSE
)
x |
( |
labels |
( |
interaction_sep |
( |
categorical_terms_pattern |
( |
model |
(a model object, e.g. |
quiet |
( |
strict |
( |
If the variable_label
column is not yet available in x
,
tidy_add_variable_labels()
will be automatically applied.
If the contrasts
column is not yet available in x
,
tidy_add_contrasts()
will be automatically applied.
It is possible to pass a custom label for any term in labels
,
including interaction terms.
Other tidy_helpers:
tidy_add_coefficients_type()
,
tidy_add_contrasts()
,
tidy_add_estimate_to_reference_rows()
,
tidy_add_header_rows()
,
tidy_add_n()
,
tidy_add_pairwise_contrasts()
,
tidy_add_reference_rows()
,
tidy_add_variable_labels()
,
tidy_attach_model()
,
tidy_disambiguate_terms()
,
tidy_identify_variables()
,
tidy_plus_plus()
,
tidy_remove_intercept()
,
tidy_select_variables()
df <- Titanic |>
dplyr::as_tibble() |>
dplyr::mutate(Survived = factor(Survived, c("No", "Yes"))) |>
labelled::set_variable_labels(
Class = "Passenger's class",
Sex = "Sex"
)
mod <-
glm(Survived ~ Class * Age * Sex, data = df, weights = df$n, family = binomial)
mod |>
tidy_and_attach() |>
tidy_add_term_labels()
mod |>
tidy_and_attach() |>
tidy_add_term_labels(
interaction_sep = " x ",
categorical_terms_pattern = "{level} / {reference_level}"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.