contr_code_difference | R Documentation |
Difference coding sets the grand mean as the intercept. Each contrast compares one level with the previous level.
contr_code_difference(fct, levels = NULL)
fct |
the factor to contrast code (or a vector) |
levels |
the levels of the factor in order |
the factor with contrasts set
df <- sim_design(between = list(pet = c("cat", "dog", "ferret")),
mu = c(2, 4, 9), empirical = TRUE, plot = FALSE)
df$pet <- contr_code_difference(df$pet)
lm(y ~ pet, df) %>% broom::tidy()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.