Description Usage Format Details References Examples
Data simulated based on summary information in Asleson et al. (1997). Deer were fed three different diets that varied in the timeing of high protein. Data are suitable for analysis with 1-way ANOVA.
1 |
A data frame
Experimental diet during both spring and summer. Hi.Hi = High quality diet in both season. Hi.Lo = high quality diet in spring but poor in summer.
Antler mass in grams
basal circumference in mm
Length of main beam of antler in mm
spread between points in mm
See the vignette "Intro to 1-way ANOVA: impacts of diet on deer antlers" for a thorough exploration of these data. The examples below demonstate basic plotting and 1-way ANOVA.
Asleson et al. 1997. Effects of seasonal protein restriction on antlerogenesis and body mass in adult male white-tailed deer. Journal of Wildlife Management 61.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ## Not run:
## Load packages
library(ggplot2)
library(ggpubr)
## Explore data graphically
### Plot boxplots
ggpubr::ggboxplot(data = antlers,
y = "mass",
x = "diet",
fill = "diet")
### Plot histograms
ggpubr::gghistogram(data = antlers,
x = "mass",
title = "All data")
#ggpubr::gghistogram(data = antlers,
# x = "mass",
facet.by = "diet",
fill = "diet",
title = "Faceted by diet")
## Plot means with 95% confidence intervals
ggpubr::ggerrorplot(antlers,
x = "diet",
y = "mass",
desc_stat = "mean_ci",
add = "mean",
ylim = c(400,900))
## 1-way ANOVA
### null model
model.null <- lm(mass ~ 1, data = antlers)
### model of interest
model.alt <- lm(mass ~ diet, data = antlers)
### compare models
anova(model.null, model.alt)
## Pairwise comparisons after 1-way ANOVA
### no corrections for multiple comparisons
pairwise.t.test(x = antlers$mass, g = antlers$diet,
p.adjust.method = "none")
### Bonferonni correction
pairwise.t.test(x = antlers$mass, g = antlers$diet,
p.adjust.method = "bonferroni")
## Tukey test
### re-fit model with aov()
model.alt.aov <- aov(mass ~ diet, data = antlers)
### TukeyHSD() on model from aov()
TukeyHSD(model.alt.aov)
### Plot effect sizes
# plotTukeysHSD(TukeyHSD(model.alt.aov))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.