View source: R/tidy_add_variable_labels.R
| tidy_add_variable_labels | R Documentation |
Will add variable labels in a var_label column, based on:
labels provided in labels argument if provided;
variable labels defined in the original data frame with
the label attribute (cf. labelled::var_label());
variable name otherwise.
tidy_add_variable_labels(
x,
labels = NULL,
interaction_sep = " * ",
instrumental_suffix = " (instrumental)",
model = tidy_get_model(x)
)
x |
( |
labels |
( |
interaction_sep |
( |
instrumental_suffix |
( |
model |
(a model object, e.g. |
If the variable column is not yet available in x,
tidy_identify_variables() will be automatically applied.
It is possible to pass a custom label for an interaction
term in labels (see examples).
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_term_labels(),
tidy_attach_model(),
tidy_disambiguate_terms(),
tidy_group_by(),
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"
)
glm(Survived ~ Class * Age * Sex, data = df, weights = df$n, family = binomial) |>
tidy_and_attach() |>
tidy_add_variable_labels(
labels = list(
"(Intercept)" ~ "Custom intercept",
Sex ~ "Gender",
"Class:Age" ~ "Custom label"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.