# Data preparation
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Tukey HSD from ANOVA results
aov(len ~ dose, data = df) %>% tukey_hsd()
# two-way anova with interaction
aov(len ~ dose*supp, data = df) %>% tukey_hsd()
# Tukey HSD from lm() results
lm(len ~ dose, data = df) %>% tukey_hsd()
# Tukey HSD from data frame and formula
tukey_hsd(df, len ~ dose)
# Tukey HSD using grouped data
df %>%
group_by(supp) %>%
tukey_hsd(len ~ dose)
Run the code above in your browser using DataLab