abundance_change {codyn} | R Documentation |
Species Abundance Changes
Description
Calculates the abundance change for species in a replicate between two time points. Changes are on abundance values provided, if relative data is used, then changes in relative abundance will be calculated.
Usage
abundance_change(
df,
time.var,
species.var,
abundance.var,
replicate.var = NULL,
reference.time = NULL
)
Arguments
df |
A data frame containing time, species, and abundance columns and an optional columns of replicates. |
time.var |
The name of the time column. |
species.var |
The name of the species column. |
abundance.var |
The name of the abundance column. |
replicate.var |
The name of the optional replicate column. If specified, replicate must be unique within the dataset and cannot be nested within treatments or blocks. |
reference.time |
The name of the optional time point that all other time points should be compared to (e.g. the first year of data). If not specified, each comparison is between consecutive time points (the first and second year, second and third year, etc.) |
Value
The abundance_change function returns a data frame with a subset of the following columns:
replicate.var: A column with the specified replicate.var, if it is specified.
time.var: A column with the specified time.var and a second column, with '2' appended to the name. Time is subtracted from time2
species.var: A column with the specified species.var.
change: A numeric column of the change in abundance between time points. A positive value occurs when a species increases in abundance over time, and a negative value when a species decreases in abundance over time.
References
Avolio et al. Submitted
Examples
data(pplots)
# Without replicates
df <- subset(pplots, plot == 25)
abundance_change(df = df,
species.var = "species",
abundance.var = "relative_cover",
time.var = "year")
# With replicates
df <- subset(pplots, year < 2004 & plot %in% c(6, 25, 32))
abundance_change(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year")
# With reference year
df <- subset(pplots, year < 2005 & plot %in% c(6, 25, 32))
abundance_change(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year",
reference.time = 2002)