## Fit a two-way ANOVA to the arousal data in arousal.df.
## The factors are gender (female, male) and picture shown to
## subject (infant, landscape, nude.f, nude.m):
data(arousal.df)
arousal.fit = lm(arousal ~ gender * picture, data = arousal.df)
## Create a data-frame with all pairwise comparisons using \code{emmeans}:
require(emmeans)
arousal.allpairs = pairs(emmeans(arousal.fit, ~gender * picture), infer = TRUE)
## Display only the within-level comparisons:
displayPairs(arousal.allpairs, levels1 = c('female', 'male'),
levels2 = c('infant', 'landscape', 'nude.f', 'nude.m'))
Run the code above in your browser using DataLab