| Title: | Match Species Names to 'IUCN' Red List Data |
|---|---|
| Description: | Facilitates matching species names with the International Union for Conservation of Nature ('IUCN') Red List of Threatened Species data. Streamlines determining conservation statuses and vernacular names through exact and fuzzy taxonomic matching. Designed to support biodiversity research and conservation planning relying on local data from the 'iucnrdata' package. |
| Authors: | Paul Efren Santos Andrade [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-6635-0375>) |
| Maintainer: | Paul Efren Santos Andrade <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.3 |
| Built: | 2026-10-12 11:33:01 UTC |
| Source: | https://github.com/PaulESantos/iucnr |
This function processes a list of species names to match their genera with a database. It first attempts to match genera exactly and then applies fuzzy matching for unmatched cases. The function provides detailed messages about the matching process, including the number of exact matches, fuzzy matches, and unmatched inputs.
filter_iucn_genus(splist, verbose = getOption("iucnr.verbose", FALSE))filter_iucn_genus(splist, verbose = getOption("iucnr.verbose", FALSE))
splist |
A character vector containing the species names to be processed. Each name should include the genus and species (e.g., "Panthera uncia"). |
verbose |
Logical value indicating whether to print informative messages.
Defaults to |
The function follows these steps:
Preprocess the species list using the helper function format_df().
Perform exact genus matching using genus_exact_match().
If there are unmatched genera, apply fuzzy matching using genus_fuzzy_match().
Combine results from both exact and fuzzy matching into a single tibble.
Identify unmatched genera and provide a summary of matching statistics via informative messages.
A tibble with the following columns:
submitted_name: The original species name submitted.
or_genus_name: The genus extracted from the submitted name.
matched_genus: The genus name that was matched (either exactly or via fuzzy matching).
direct_match_genus: A logical value indicating whether the genus was matched exactly.
fuzzy_match_genus: A logical value indicating whether the genus was matched using fuzzy matching.
If any genera remain unmatched, they will have NA in the matched_genus column, and both direct_match_genus and fuzzy_match_genus will be FALSE or NA.
filter_iucn_genus(c("Panthera uncia", "Cedrela odorata"))filter_iucn_genus(c("Panthera uncia", "Cedrela odorata"))
Matches the genus names from a given tibble to a reference IUCN genus dataset and returns a tibble with the matching status.
genus_exact_match(df)genus_exact_match(df)
df |
A tibble, result of internal function |
The function:
Matches the genus names in or_genus_name to the IUCN genus dataset
(iucnr::iucn_genus).
Combines matched and unmatched rows, adding a boolean indicator
column (direct_match_genus) to show match status.
The reference dataset iucnr::iucn_genus is an internal dataset included
in the iucrn package.
A tibble with the following columns:
Original submitted name from the input tibble.
Original genus name from the input tibble.
Matched genus name from the IUCN reference dataset, or NA if no match was found.
Logical column indicating whether the genus was successfully matched (TRUE) or not (FALSE).
df <- iucnr:::format_df(c("Panthera uncia", "Cedrela odorata")) genus_exact_match(df)df <- iucnr:::format_df(c("Panthera uncia", "Cedrela odorata")) genus_exact_match(df)
Tries to fuzzy match the genus name from the input dataset to the
IUCN genus list (iucnr::iucn_genus).
Uses fuzzyjoin::stringdist_left_join() for approximate string matching,
allowing for minor differences in the genus names.
genus_fuzzy_match(df)genus_fuzzy_match(df)
df |
A |
The function handles cases where the genus name in the input data differs slightly (e.g., due to typos). It assigns the closest match based on string distance (with a maximum distance of 1) and identifies unmatched entries. For genera with multiple fuzzy matches, the function issues a warning, saves the ambiguous matches to a CSV file, and proceeds by selecting the first match. The user is advised to manually curate these ambiguous cases and re-run the function if necessary.
Returns a tibble with aditional columns with information aboout fuzzy matching:
matched_genus: Contains the matched genus name (if a match was found) or NA otherwise.
fuzzy_match_genus: Logical column indicating whether the genus was successfully matched (TRUE) or not (FALSE).
fuzzy_genus_dist: The string distance between the original and matched genus names (only for matched rows).
# Example input tibble df <- tibble::tibble( submitted_name = c("Panthera uncia", "Lynx lynx", "Ara militaris", "Zonotrichia capencis", "Cyathula coriaceas", "Impatienss confussa"), or_genus_name = c("Panthera", "Lynx", "Ara", "Zonotrichia", "Cyathula", "Impatienss") ) # Exact match node_1_processed <- genus_exact_match(df) # Fuzzy matching node_1_FALSE <- node_1_processed |> dplyr::filter(direct_match_genus == FALSE) node_2_processed <- genus_fuzzy_match(node_1_FALSE) print(node_2_processed)# Example input tibble df <- tibble::tibble( submitted_name = c("Panthera uncia", "Lynx lynx", "Ara militaris", "Zonotrichia capencis", "Cyathula coriaceas", "Impatienss confussa"), or_genus_name = c("Panthera", "Lynx", "Ara", "Zonotrichia", "Cyathula", "Impatienss") ) # Exact match node_1_processed <- genus_exact_match(df) # Fuzzy matching node_1_FALSE <- node_1_processed |> dplyr::filter(direct_match_genus == FALSE) node_2_processed <- genus_fuzzy_match(node_1_FALSE) print(node_2_processed)
Filters IUCN species data from the packaged dataset by Red List conservation status
categories such as Critically Endangered ("CR"), Endangered ("EN"), Vulnerable ("VU"), etc.
get_iucn_by_category(category = c("CR", "EN", "VU"), format = "tbl")get_iucn_by_category(category = c("CR", "EN", "VU"), format = "tbl")
category |
Character vector specifying the Red List conservation status categories to filter by.
Accepts short codes (e.g., |
format |
A character string specifying the output format:
|
Depending on format: a tibble or a character vector of species scientific names.
# Get all Critically Endangered and Endangered species cr_en_species <- get_iucn_by_category(category = c("CR", "EN"), format = "tbl") head(cr_en_species)# Get all Critically Endangered and Endangered species cr_en_species <- get_iucn_by_category(category = c("CR", "EN"), format = "tbl") head(cr_en_species)
Filters IUCN species and conservation status data by higher taxonomic ranks such as kingdom, phylum, class, order, family, or genus.
get_iucn_by_taxonomy( kingdom = NULL, phylum = NULL, class = NULL, order = NULL, family = NULL, genus = NULL, status = NULL, format = "tbl" )get_iucn_by_taxonomy( kingdom = NULL, phylum = NULL, class = NULL, order = NULL, family = NULL, genus = NULL, status = NULL, format = "tbl" )
kingdom |
Optional character string or vector specifying kingdom name(s) (e.g., |
phylum |
Optional character string or vector specifying phylum name(s). |
class |
Optional character string or vector specifying class name(s) (e.g., |
order |
Optional character string or vector specifying order name(s) (e.g., |
family |
Optional character string or vector specifying family name(s) (e.g., |
genus |
Optional character string or vector specifying genus name(s) (e.g., |
status |
Optional character vector to filter by Red List conservation status category.
Accepts short codes (e.g., |
format |
A character string specifying the output format:
|
Depending on format: a tibble or a character vector of species scientific names.
# Search Endangered or Critically Endangered species in Felidae family felidae_threatened <- get_iucn_by_taxonomy( family = "Felidae", status = c("CR", "EN"), format = "tbl" ) head(felidae_threatened)# Search Endangered or Critically Endangered species in Felidae family felidae_threatened <- get_iucn_by_taxonomy( family = "Felidae", status = c("CR", "EN"), format = "tbl" ) head(felidae_threatened)
This function retrieves vernacular (common) names for species using IUCN data.
It filters vernacular names based on the taxonID and merges them
with species metadata. The output can be customized as either a vector of common names
or a tibble containing detailed information.
get_iucn_common_name( splist, format = "vect", verbose = getOption("iucnr.verbose", FALSE) )get_iucn_common_name( splist, format = "vect", verbose = getOption("iucnr.verbose", FALSE) )
splist |
A character vector containing the scientific names of species for which vernacular names are to be retrieved. |
format |
A character string specifying the output format. Options are:
|
verbose |
Logical value indicating whether to print informative messages.
Defaults to |
Depending on the format argument:
If "vect", a character vector of common names.
If "tbl", a tibble with the following columns:
The scientific name of the species as submitted.
The matched species name from IUCN data.
The vernacular (common) name. If no common name is found, it returns "---".
species <- c("Panthera uncia", "Cedrela odorata") result <- get_iucn_common_name(splist = species, format = "tbl") print(result) common_names <- get_iucn_common_name(splist = species, format = "vect") print(common_names)species <- c("Panthera uncia", "Cedrela odorata") result <- get_iucn_common_name(splist = species, format = "tbl") print(result) common_names <- get_iucn_common_name(splist = species, format = "vect") print(common_names)
This function retrieves the conservation status of species from the iucn_data dataset.
It supports multiple species names and uses data.table for efficient performance.
The output format can be customized to either a vector of conservation statuses or a tibble.
get_iucn_status( splist, format = "vect", verbose = getOption("iucnr.verbose", FALSE) )get_iucn_status( splist, format = "vect", verbose = getOption("iucnr.verbose", FALSE) )
splist |
A character vector containing species names to search for in the |
format |
A character string specifying the output format. Options are:
|
verbose |
Logical value indicating whether to print informative messages.
Defaults to |
A vector or tibble, depending on the specified format, with species names and their corresponding conservation statuses.
If no match is found for a species, it will return "no match found".
species <- c("Panthera uncia", "Cedrela odorata") result <- get_iucn_status(splist = species, format = "tbl") print(result)species <- c("Panthera uncia", "Cedrela odorata") result <- get_iucn_status(splist = species, format = "tbl") print(result)
Returns information about the version of the IUCN Red List data snapshot
packaged and available in the offline environment (iucnrdata).
iucn_data_version(details = FALSE)iucn_data_version(details = FALSE)
details |
A logical value. If |
Depending on details: a character string or a tibble containing version metadata.
# Get version string iucn_data_version() # Get detailed version metadata iucn_data_version(details = TRUE)# Get version string iucn_data_version() # Get detailed version metadata iucn_data_version(details = TRUE)
The iucn_genus dataset is part of the iucnr package and contains information on the genera
of various species listed in the IUCN Red List of Threatened Species. Each genus is associated
with one or more internal identifiers corresponding to its listings within the IUCN database.
iucn_genusiucn_genus
A tibble with 22,813 rows and 2 columns:
Character. The name of the genus.
Character. A string of internal IUCN identifiers for each genus, separated by " - " when multiple identifiers are present.
This dataset provides a comprehensive reference for genus-level classifications in the
IUCN database, facilitating taxonomic analyses and cross-referencing with other species
data. The internal_ids column can include multiple identifiers, representing various
listings for the same genus within the IUCN records.
IUCN Red List of Threatened Species
This function matches a list of species against the IUCN database using genus filtering, exact species matching, and fuzzy species matching. The output includes matched species along with their IUCN Red List category and criteria.
iucn_match(splist, verbose = getOption("iucnr.verbose", FALSE))iucn_match(splist, verbose = getOption("iucnr.verbose", FALSE))
splist |
A dataframe or character vector containing species names to be matched. |
verbose |
Logical value indicating whether to print informative messages.
Defaults to |
A dataframe with the following columns:
id: Row number identifier.
submitted_name: Original species names from the input.
matched_species: Matched species name from the IUCN database (or --- if not matched).
redlist_category: Red List category of the matched species (or --- if not available).
internal_taxon_id: IUCN taxon identifier (or NA).
iucn_match(c("Panthera uncia", "Cedrela odorata"))iucn_match(c("Panthera uncia", "Cedrela odorata"))
This function matches species names (submitted_name) from the input dataframe directly to the IUCN species list.
It identifies matches and non-matches based on exact string comparison, and returns a dataframe with match status
and relevant columns.
species_direct_match(df)species_direct_match(df)
df |
A dataframe containing species names in the column |
A dataframe that includes:
submitted_name: Original species names from the input.
matched_genus: The genus matched from the input.
matched_species: The species name matched directly in the IUCN dataset.
direct_match_species: Boolean indicating whether the species was directly matched (TRUE) or not (FALSE).
df <- filter_iucn_genus("Panthera uncia") species_direct_match(df)df <- filter_iucn_genus("Panthera uncia") species_direct_match(df)
This function matches a dataframe of species names (submitted_name) to the IUCN database using fuzzy string matching.
It returns a dataframe with matched and unmatched entries, including additional details on the matching process.
species_fuzzy_match(df)species_fuzzy_match(df)
df |
A dataframe containing species names in the column |
A dataframe with the original input, matched species names, fuzzy string distances, and match status.
df <- filter_iucn_genus("Panthera uncia") species_fuzzy_match(df)df <- filter_iucn_genus("Panthera uncia") species_fuzzy_match(df)