Calculates the area difference between two rank abundance curves. There are three ways differences can be calculated. 1) Between all treatments within a block (note: block.var and treatment.var need to be specified. 2) Between treatments, pooling all replicates into a single species pool (note: pool = TRUE, treatment.var needs to be specified, and block.var = NULL. 3) All pairwise combinations between all replicates (note:block.var = NULL, pool = FALSE and specifying treatment.var is optional. If treatment.var is specified, the treatment that each replicate belongs to will also be listed in the output).
Usage
curve_difference(
df,
time.var = NULL,
species.var,
abundance.var,
replicate.var,
treatment.var = NULL,
pool = FALSE,
block.var = NULL,
reference.treatment = NULL
)Arguments
- df
A data frame containing a species, abundance, and replicate columns and optional time, treatment, and block columns.
- time.var
The name of the optional time column.
- species.var
The name of the species column.
- abundance.var
The name of the abundance column.
- replicate.var
The name of the replicate column. Replicate identifiers must be unique within the dataset and cannot be nested within treatments or blocks.
- treatment.var
The name of the optional treatment column.
- pool
An argument to allow abundance values to be pooled within a treatment. The default value is "FALSE", a value of "TRUE" averages abundance of each species within a treatment at a given time point.
- block.var
The name of the optional block column.
- reference.treatment
The name of the optional treatment that all other treatments will be compared to (e.g. only controls will be compared to all other treatments). If not specified all pairwise treatment comparisons will be made.
Value
The curve_difference function returns a data frame with the following attributes: - **curve_diff**: A numeric column of the area difference in curves between the two samples being compared (replicates or treatments). - **replicate.var**: A column that has same name and type as the replicate.var column, represents the first replicate being compared. Note, a replicate column will be returned only when pool is FALSE or block.var = NULL. - **replicate.var2**: A column that has the same type as the replicate.var column, and is named replicate.var with a 2 appended to it, represents the second replicate being compared. Note, a replicate.var column will be returned only when pool is FALSE and block.var = NULL. - **time.var**: A column that has the same name and type as the time.var column, if time.var is specified. - **treatment.var**: A column that has same name and type as the treatment.var column, represents the first treatment being compared. A treatment.var column will be returned when pool is TRUE or block.var is specified, or treatment.var is specified. - **treatment.var2**: A column that has the same type as the treatment.var column, and is named treatment.var with a 2 appended to it, represents the second treatment being compared. A treatment.var column will be returned when pool is TRUE or block.var is specified, or treatment.var is specified. - **block.var**: A column that has same name and type as the block.var column, if block.var is specified.
Examples
data(pplots)
# With block and no time
df <- subset(pplots, year == 2002 & block < 3)
curve_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment",
block.var = "block",
replicate.var = "plot")
#> block plot plot2 treatment treatment2 curve_diff
#> 1 1 25 13 N1P0 N2P3 0.042342507
#> 2 1 29 13 N2P0 N2P3 0.038141570
#> 3 1 25 29 N1P0 N2P0 0.008164927
#> 4 2 27 21 N1P0 N2P3 0.031471972
#> 5 2 32 21 N2P0 N2P3 0.033554035
#> 6 2 27 32 N1P0 N2P0 0.034134255
# With blocks and time
df <- subset(pplots, year < 2004 & block < 3)
curve_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment",
block.var = "block",
replicate.var = "plot",
time.var = "year")
#> year block plot plot2 treatment treatment2 curve_diff
#> 1 2002 1 25 13 N1P0 N2P3 0.042342507
#> 2 2002 1 29 13 N2P0 N2P3 0.038141570
#> 3 2002 1 25 29 N1P0 N2P0 0.008164927
#> 4 2002 2 27 21 N1P0 N2P3 0.031471972
#> 5 2002 2 32 21 N2P0 N2P3 0.033554035
#> 6 2002 2 27 32 N1P0 N2P0 0.034134255
#> 7 2003 1 25 13 N1P0 N2P3 0.043545060
#> 8 2003 1 29 13 N2P0 N2P3 0.055121911
#> 9 2003 1 25 29 N1P0 N2P0 0.025078149
#> 10 2003 2 27 21 N1P0 N2P3 0.023707724
#> 11 2003 2 32 21 N2P0 N2P3 0.049140068
#> 12 2003 2 27 32 N1P0 N2P0 0.054475881
# With blocks, time, and reference treatment
df <- subset(pplots, year < 2004 & block < 3)
curve_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment",
block.var = "block",
replicate.var = "plot",
time.var = "year",
reference.treatment = "N1P0")
#> year block plot plot2 treatment treatment2 curve_diff
#> 1 2002 1 25 13 N1P0 N2P3 0.042342507
#> 2 2002 1 25 29 N1P0 N2P0 0.008164927
#> 3 2002 2 27 21 N1P0 N2P3 0.031471972
#> 4 2002 2 27 32 N1P0 N2P0 0.034134255
#> 5 2003 1 25 13 N1P0 N2P3 0.043545060
#> 6 2003 1 25 29 N1P0 N2P0 0.025078149
#> 7 2003 2 27 21 N1P0 N2P3 0.023707724
#> 8 2003 2 27 32 N1P0 N2P0 0.054475881
# Pooling by treatment with time
df <- subset(pplots, year < 2004)
curve_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment",
pool = TRUE,
replicate.var = "plot",
time.var = "year")
#> year treatment treatment2 curve_diff
#> 1 2002 N1P0 N2P0 0.012844729
#> 2 2002 N1P0 N2P3 0.008499713
#> 3 2002 N2P0 N2P3 0.015928584
#> 4 2003 N1P0 N2P0 0.010885645
#> 5 2003 N1P0 N2P3 0.008337827
#> 6 2003 N2P0 N2P3 0.011247054
# All pairwise replicates with treatment
df <- subset(pplots, year < 2004 & plot %in% c(21, 25, 32))
curve_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year",
treatment.var = "treatment")
#> year plot plot2 treatment treatment2 curve_diff
#> 1 2002 21 25 N2P3 N1P0 0.02309084
#> 2 2002 21 32 N2P3 N2P0 0.03355403
#> 3 2002 25 32 N1P0 N2P0 0.02963381
#> 4 2003 21 25 N2P3 N1P0 0.02567894
#> 5 2003 21 32 N2P3 N2P0 0.04914007
#> 6 2003 25 32 N1P0 N2P0 0.06171828
# All pairwise replicates without treatment
df <- subset(pplots, year < 2004 & plot %in% c(21, 25, 32))
curve_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year")
#> year plot plot2 curve_diff
#> 1 2002 21 25 0.02309084
#> 2 2002 21 32 0.03355403
#> 3 2002 25 32 0.02963381
#> 4 2003 21 25 0.02567894
#> 5 2003 21 32 0.04914007
#> 6 2003 25 32 0.06171828