contr_code_difference: Difference code a factor

Description Usage Arguments Value Examples

View source: R/contrasts.R

Description

Difference coding sets the grand mean as the intercept. Each contrast compares one level with the previous level.

Usage

1

Arguments

fct

the factor to contrast code (or a vector)

levels

the levels of the factor in order

Value

the factor with contrasts set

Examples

1
2
3
4
5
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()

faux documentation built on Sept. 14, 2021, 1:08 a.m.