Skip to contents

Given a data frame of taxa names, searches FishBase and SeaLifeBase for matching species. Matching is attempted at multiple taxonomic ranks: species (binomial), genus, family, order, and class. This allows coarser records (e.g. `"Lutjanidae spp"`) to expand to all species in that family.

Usage

expand_taxonomic_info(data)

Arguments

data

A data frame with at minimum the following columns: - `alpha3_code`: Three-letter country/region code. - `scientific_name`: Scientific name at any taxonomic rank; trailing ` spp` is stripped before matching.

Value

A tibble with columns: - `alpha3_code`: Passed through from input. - `original_name`: The original `scientific_name` value. - `SpecCode`: FishBase / SeaLifeBase species identifier. - `species_found`: Matched binomial species name. - `server`: Source database (`"fishbase"` or `"sealifebase"`).

Details

The function builds a lookup dictionary by pivoting the taxonomy backbone wide-to-long across ranks, so a single join resolves names at any level. Records that do not match any rank are silently dropped (inner join).

Examples

if (FALSE) { # \dontrun{
taxa <- data.frame(
  alpha3_code = c("KEN", "TZA"),
  scientific_name = c("Lethrinus nebulosus", "Lutjanidae")
)
expand_taxonomic_info(taxa)
} # }