Description Usage Format References Examples
Original data had lat and long for most sites. Elevations estimate using the elevatr package (https://cran.r-project.org/web/packages/elevatr/vignettes/introduction_to_elevatr.html)
1 |
A data frame
latitude of survey site
longitude of survey site
Are pikas present or absent from the site
Are marmots present or absent
Description of area of talus at site
Elevation of site
Designates whether no focal species seen, pikas only, marmots only, or both
Front Range Pika Project. http://www.pikapartners.org/cwis438/websites/FRPP/Home.php?WebSiteID=18
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 | ## Load packages
library(ggplot2)
library(ggpubr)
## Explore data graphically
### Plot boxplots
ggboxplot(data = pikas,
y = "elev.m",
x = "group",
fill = "group")
### Plot histograms
gghistogram(data = pikas,
x = "elev.m",
title = "All data")
gghistogram(data = pikas,
x = "elev.m",
facet.by = "group",
fill = "group",
title = "Faceted by group")
## Plot means with 95% confidence intervals
ggerrorplot(pikas,
x = "group",
y = "elev.m",
desc_stat = "mean_ci",
add = "mean")
## 1-way ANOVA
### null model
model.null <- lm(elev.m ~ 1, data = pikas)
### model of interest
model.alt <- lm(elev.m ~ group, data = pikas)
### compare models
anova(model.null, model.alt)
## Pairwise comparisons after 1-way ANOVA
### no corrections for multiple comparisons
pairwise.t.test(x = pikas$elev.m, g = pikas$group,
p.adjust.method = "none")
### Bonferonni correction
pairwise.t.test(x = pikas$elev.m, g = pikas$group,
p.adjust.method = "bonferroni")
## Tukey test
### re-fit model with aov()
model.alt.aov <- aov(elev.m ~ group, data = pikas)
### TukeyHSD() on model from aov()
TukeyHSD(model.alt.aov)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.