| tukey_hsd | R Documentation |
Provides a pipe-friendly framework to performs Tukey post-hoc
tests. Wrapper around the function TukeyHSD(). It is
essentially a t-test that corrects for multiple testing.
Can handle different inputs formats: aov, lm, formula.
See the Datanovia tutorial One-Way ANOVA in R for a worked walkthrough.
tukey_hsd(x, ...)
## Default S3 method:
tukey_hsd(x, ...)
## S3 method for class 'lm'
tukey_hsd(x, ...)
## S3 method for class 'data.frame'
tukey_hsd(x, formula, ...)
x |
an object of class |
... |
other arguments passed to the function
|
formula |
a formula of the form |
data |
a data.frame containing the variables in the formula. |
a tibble data frame containing the results of the different comparisons.
tukey_hsd(default): performs tukey post-hoc test from aov() results.
tukey_hsd(lm): performs tukey post-hoc test from lm() model.
tukey_hsd(data.frame): performs tukey post-hoc tests using data and formula as
inputs. ANOVA will be automatically performed using the function
aov()
The Datanovia tutorial: One-Way ANOVA in R.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.