broom.helpers (version 1.0.0)

tidy_add_contrasts: Add contrasts type for categorical variables

Description

Add a contrasts column corresponding to the type of contrasts

Usage

tidy_add_contrasts(x, model = tidy_get_model(x))

Arguments

x

a tidy tibble

model

the corresponding model, if not attached to x

Details

If the variable column is not yet available in x, tidy_identify_variables() will be automatically applied.

See Also

Other tidy_helpers: tidy_add_estimate_to_reference_rows(), tidy_add_header_rows(), tidy_add_reference_rows(), tidy_add_term_labels(), tidy_add_variable_labels(), tidy_attach_model(), tidy_identify_variables(), tidy_plus_plus(), tidy_remove_intercept()

Examples

Run this code
# NOT RUN {
df <- Titanic %>%
  dplyr::as_tibble() %>%
  dplyr::mutate(Survived = factor(Survived, c("No", "Yes")))

df %>%
  glm(
    Survived ~ Class + Age + Sex,
    data = ., weights = .$n, family = binomial,
    contrasts = list(Age = contr.sum, Class = "contr.helmert")
  ) %>%
  tidy_and_attach() %>%
  tidy_add_contrasts()
# }

Run the code above in your browser using DataLab