Populates key life-history traits in a data frame of species using FishBase, via the rfishbase
package.
Usage
fillDefaultsFromFishBase(
species_params,
scientific_name_col = "Scientific_name",
overwrite = FALSE,
verbose = TRUE
)
Arguments
- species_params
A data frame containing at least a column with scientific names for each species. Other columns (e.g. common names or user-defined identifiers) may be included and will be preserved. This is typically a minimal table created at the start of model construction (e.g., from a species list), not yet a full
species_params
object.- scientific_name_col
A string giving the column name in
species_params
that holds the scientific names. Defaults to"Scientific_name"
.- overwrite
Logical (default =
FALSE
). IfTRUE
, existing values in the data frame are replaced by FishBase values. IfFALSE
, only missing values are filled.- verbose
Logical (default =
TRUE
). IfTRUE
, prints a summary of filled species.
Value
The same data frame, augmented with the following columns where data are available:
a
,b
: Length–weight allometric coefficientsLength
: Maximum length (cm)w_max
: Maximum weight (calculated from Length, a, and b)l_mat
: Length at maturity (median)age_mat
: Age at maturity (median)w_mat
: Weight at maturity (from l_mat, a, and b)
Details
This function is typically used early in model setup, to populate a table of species names with biological parameters needed for Mizer models. It supports cases where only species names and scientific names are initially known.
This is a convenience function that queries FishBase through the rfishbase
package.
Traits are pulled from the estimate()
, maturity()
, and species()
tables. Maturity traits
are summarised by median within FishBase SpecCode
groups. Derived weights are calculated from
length–weight relationships.
Existing columns in the input will only be overwritten if overwrite = TRUE
.
Examples
if (FALSE) { # \dontrun{
# Minimal example with only scientific names
species_df <- data.frame(
Scientific_name = c("Merluccius merluccius", "Scomber scombrus")
)
enriched <- fillDefaultsFromFishBase(species_df)
# Optional: include user-defined species labels
species_df <- data.frame(
species = c("Hake", "Mackerel"),
Scientific_name = c("Merluccius merluccius", "Scomber scombrus")
)
enriched <- fillDefaultsFromFishBase(species_df)
} # }