Description Usage Arguments Value References Examples
View source: R/abundance_difference.R
Calculates the abundance difference for species between two samples. Differences are on abundance values provided, if relative data is used, then differences in relative abundance will be calculated. There are three ways differences can be calculated. 1) Between 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).
1 2 3 4 5 6 7 8 9 10 11 |
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. |
The abundance_difference function returns a data frame with a subset of the following columns:
species.var: A column that has same name and type as the species.var column.
difference: A numeric column of the abundance differences between the two samples being compared (replicates or treatments). A numeric column of the change in abundance between consecutive timepoints. A positive value occurs when a species has greater abundance in replicate.var2 than in replicate.var and/or in treatment.var2 than in treatment.var.
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 = 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 = 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 = TRUE, 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 = TRUE, 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.
Avolio et al. Submitted
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 | data(pplots)
# With block and no time
df <- subset(pplots, year == 2002 & block < 3)
abundance_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment",
block.var = "block",
replicate.var = "plot")
# With blocks and time
df <- subset(pplots, year < 2004 & block < 3)
abundance_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment",
block.var = "block",
replicate.var = "plot",
time.var = "year")
# With blocks, time and reference treatment
df <- subset(pplots, year < 2004 & block < 3)
abundance_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")
# Pooling by treatment with time
df <- subset(pplots, year < 2004)
abundance_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
treatment.var = "treatment",
pool = TRUE,
replicate.var = "plot",
time.var = "year")
# All pairwise replicates with treatment
df <- subset(pplots, year < 2004 & plot %in% c(21, 25, 32))
abundance_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year",
treatment.var = "treatment")
# All pairwise replicates without treatment
df <- subset(pplots, year < 2004 & plot %in% c(21, 25, 32))
abundance_difference(df = df,
species.var = "species",
abundance.var = "relative_cover",
replicate.var = "plot",
time.var = "year")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.