ANOVA
Up to now, you've created output objects to save and extract elements for customized and more detailed presentation of results. However, some output objects like those from the aov()
function for running an analysis of variance (ANOVA) can be used as inputs to other functions such as summary()
and plot()
to get customized results reporting and visualizations. The aov()
output can also be used as input to TukeyHSD()
to perform post hoc pairwise testing.
The abaloneKeep
dataset and dplyr
package have been loaded for you.
This exercise is part of the course
R For SAS Users
Exercise instructions
- Compute
n
, mean, standard deviation, and variance of age by sex. - Perform an ANOVA of
age
bysex
groups and save the output asabaov
. - Run the
summary()
ofabaov
. - Perform
TukeyHSD()
posthoc pairwise tests onabaov
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Compute n(), mean(), sd() and var() of age by sex
abaloneKeep %>% group_by(___) %>% select(___, ___) %>%
summarise(across(everything(), list(mean = ___,
___ = ~sd(.x),
var = ___)),
N = ___)
# Run aov() of age by sex, save as abaov
abaov <- aov(___ ~ ___, data = ___)
# Run summary() of abaov
___
# Perform TukeyHSD posthoc pairwise tests on abaov
TukeyHSD(___)