This function can optionally remove attempts for species identified as hybrids, "spuhs", or "slashes" and perform a "taxonomic roll up" of subspecies to the species level.
Usage
nw.cleantaxa(
data,
spuh = FALSE,
slash = FALSE,
hybrid = FALSE,
rollsubspecies = FALSE,
output = NULL
)
Arguments
- data
dataframe; A dataframe containing NestWatch data.
- spuh
logical; Should attempt with "sp." be removed?
if
NULL
, the default, retains identified rows in the output dataframe.if
TRUE
, removes identified rows from the output dataframe.if
FALSE
, retains identified rows in the output dataframe.
- slash
logical; Should attempt with "/" be removed?
if
NULL
, the default, retains identified rows in the output dataframe.if
TRUE
, removes identified rows from the output dataframe.if
FALSE
, retains identified rows in the output dataframe.
- hybrid
logical; Should attempt with "(hybrid)" be removed?
if
NULL
, the default, retains identified rows in the output dataframe.if
TRUE
, removes identified rows from the output dataframe.if
FALSE
, retains identified rows in the output dataframe.
- rollsubspecies
logical; Should attempt with Species.Name of the form "species (subspecies/form) be rolled up to the species level? Uses the current eBird taxonomy as in
auk::ebird_taxonomy
.if
NULL
, the default, retains original Species.Names and Species.Codes.if
TRUE
, performs taxonomic roll up for all attempts with subspecies/form designation and updates Species.Code.if
FALSE
, retains original Species.Names and Species.Codes.
- output
character; An optional character string to custom name the output dataframe
Details
The NestWatch platform uses eBird taxonomy to help users auto-complete species names. This allows users to select any
available eBird taxonomic unit, including spuhs (ie. "chickadee sp."), slashes (ie. "Tree/Violet-green Swallow"),
and subspecies/forms (ie."House Wren (northern)"). In some cases, the user may decide to omit spuhs and slashes because species
is not known with certainty. Or the user may want to analyze all subspecies/forms of a species together if these differentiations
are not biologically relevant to the analysis. This function will update both the Common Name and Species Code of the attempt
according to the current version of eBird taxonomy in auk::ebird_taxonomy
.
Examples
# Data with species name variations
df <- data.frame(Attempt.ID = c(1, 1, 2, 3, 4),
Species.Name = c("House Wren (northern)", "House Wren (northern)",
"chickadee sp.", "Tree/Violet-green Swallow",
"Mallard x American Black Duck (hybrid)"),
Species.Code = c("houwre1", "houwre1", "chicka1", "y00701", "x00004"))
# Remove just ".sp" attempts
nw.cleantaxa(df, spuh = TRUE)
# Remove "/" and hybrid attempts, roll up subspecies to species
nw.cleantaxa(df, slash = TRUE, hybrid = TRUE, rollsubspecies = TRUE)