-
Notifications
You must be signed in to change notification settings - Fork 0
/
wetlands.R
85 lines (82 loc) · 2.31 KB
/
wetlands.R
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#' Data on species richness in constructed wetlands at Pennsylvania Game Lands 297 in south western PA.
#'
#' Data are the number of species observed in a 0.25 m^2 plot.
#' The original data include the number of stems and percentage
#' cover of each species within the sampling plot.
#' Data collected by Gerry Koza (koz7133@calu.edu) in the summer 2017.
#'
#' @format A data frame with 78 rows and 5 variables:
#' \describe{
#' \item{site}{Gameland}
#' \item{wetland}{Wetland number. Can be 1 2 or3}
#' \item{Plot}{Transect an plot designations}
#' \item{water.depth}{depth of water within sapling plot}
#' \item{spp.richness}{The number of species observed within the sampling plot}
#' }
#'
#' @examples
#' ## Load packages
#'
#' library(ggplot2)
#' library(ggpubr)
#'
#' ## Set wetland as a factor
#' wetlands$wetland <- factor(wetlands$wetland)
#'
#' ## Explore data graphically
#'
#' ### Plot boxplots
#' ggboxplot(data = wetlands,
#' y = "spp.richness",
#' x = "wetland",
#' fill = "wetland")
#'
#' ### Plot histograms
#' gghistogram(data = wetlands,
#' x = "spp.richness",
#' title = "All data")
#'
#'g ghistogram(data = wetlands,
#' x = "spp.richness",
#' facet.by = "wetland",
#' fill = "wetland",
#' title = "Faceted by wetland")
#'
#' ## Plot means with 95% confidence intervals
#' ggerrorplot(wetlands,
#' x = "wetland",
#' y = "spp.richness",
#' desc_stat = "mean_ci",
#' add = "mean")
#'
#' ## 1-way ANOVA
#'
#' ### null model
#' model.null <- lm(spp.richness ~ 1, data = wetlands)
#'
#' ### model of interest
#' model.alt <- lm(spp.richness ~ wetland, data = wetlands)
#'
#' ### compare models
#' anova(model.null, model.alt)
#'
#' ## Pairwise comparisons after 1-way ANOVA
#' ### no corrections for multiple comparisons
#' pairwise.t.test(x = wetlands$spp.richness, g = wetlands$wetland,
#' p.adjust.method = "none")
#'
#' ### Bonferonni correction
#' pairwise.t.test(x = wetlands$spp.richness, g = wetlands$wetland,
#' p.adjust.method = "bonferroni")
#'
#' ## Tukey test
#'
#' ### re-fit model with aov()
#' model.alt.aov <- aov(spp.richness ~ wetland, data = wetlands)
#'
#' ### TukeyHSD() on model from aov()
#' TukeyHSD(model.alt.aov)
#'
#' ### Plot effect sizes
#' plotTukeysHSD(TukeyHSD(model.alt.aov))
"wetlands"