After today’s session you will be able to:
ggplot2
dplyr
, tidyr
, base R, etc.
vegan
package!
diversity
and specnumber
# Calculate diversity
vegan::diversity(x = community_df, index = "shannon")
# Calculate richness
vegan::specnumber(x = community_df)
vegan
vegan
has some built-in community datasets
vegan
package
specnumber
function in vegan
vegan
is rarefy
# Rarefy our community data
vegan::rarefy(x = community_df,
# `sample` argument is minimum abundance
sample = min(community_df$abundance))
sample
to 20)
rowSums(BCI)
and assign it to an objectmin
on that object to identify the single smallest value
sample
to the minimum value you found
vegan
is specaccum
specaccum
on the BCI data and assign it to a new object
ggplot2
will want a dataframe so we need to do some parsing
curve_df <- data.frame("sites" = curve_list$sites,
"richness" = curve_list$richness,
"sd" = curve_list$sd)
curve_list
should be whatever you named your species accumulation object
ggplot2
to make a graph with:
theme
elements in ways that spark joy for you
color
to sites
ggplot2
Geometrygeom_errorbar
)
# Make plot
ggplot() +
# Add (vertical) error bars
geom_errorbar(aes(ymin = y - g,
ymax = y + g),
width = 0.5)
y
= name of column mapped to Y axisg
= name of column to add/subtract from Y axiswidth
= how wide you want the crossbars on the error bars
geom_errorbar
aes
parentheses ymin/ymax should +/- the “sd” column
width
to whatever you’d like