Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tidy_add_contrasts

Add contrasts type for categorical variables


Description

Add a contrasts column corresponding to contrasts used for a categorical variable and a contrasts_type column equal to "treatment", "sum", "poly", "helmert", "other" or "no.contrast".

Usage

tidy_add_contrasts(x, model = tidy_get_model(x), quiet = FALSE)

Arguments

x

a tidy tibble

model

the corresponding model, if not attached to x

quiet

logical argument whether broom.helpers should not return a message when tidy_disambiguate_terms() was already applied

Details

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

See Also

Examples

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()

broom.helpers

Helpers for Model Coefficients Tibbles

v1.3.0
GPL-3
Authors
Joseph Larmarange [aut, cre] (<https://orcid.org/0000-0001-7097-700X>), Daniel D. Sjoberg [aut] (<https://orcid.org/0000-0003-0862-2018>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.