Calculates the area difference between two rank abundance curves between two time periods. If replicate is specified, it must be measured in both time points, otherwise it will be dropped for that time period comparison.
Usage
curve_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 curve_change function returns a data frame with the following attributes: - **time.var**: A column with the specified time.var and a second column, with '2' appended to the name. Time is subtracted from time2. - **curve_change**: A numeric column of the change in curves between time points. - **replicate.var**: A column that has same name and type as the replicate.var column, if specified.
Examples
data(pplots)
# Without replicates
df <- subset(pplots, plot == 25)
curve_change(df = df,
species.var = "species",
abundance.var = "relative_cover",
time.var = "year")
#> year year2 curve_change
#> 5 2002 2003 0.03259107
#> 10 2003 2004 0.04098240
#> 15 2004 2005 0.07383364
# With replicates
df <- subset(pplots, year < 2004 & plot %in% c(6, 25, 32))
curve_change(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year")
#> year year2 plot curve_change
#> 1 2002 2003 6 0.04780344
#> 2 2002 2003 25 0.03259107
#> 3 2002 2003 32 0.03634063
# With reference year
df <- subset(pplots, year < 2005 & plot %in% c(6, 25, 32))
curve_change(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year",
reference.time = 2002)
#> year year2 plot curve_change
#> 1 2002 2003 6 0.04780344
#> 2 2002 2004 6 0.01845279
#> 3 2002 2003 25 0.03259107
#> 4 2002 2004 25 0.02217456
#> 5 2002 2003 32 0.03634063
#> 6 2002 2004 32 0.02264086