search_avesperu: Search for Bird Species Data in the Birds of Peru Dataset

View source: R/get_avesperu.R

search_avesperuR Documentation

Search for Bird Species Data in the Birds of Peru Dataset

Description

This function searches for bird species information in the dataset provided by the avesperu package, given a list of species names. It supports approximate (fuzzy) matching to handle typographical errors or minor variations in the species names. The function returns detailed information for each species, including taxonomic data, common names, and status.

Usage

search_avesperu(splist, max_distance = 0.1)

Arguments

splist

A character vector containing the names of bird species to search for. Names can include minor variations or typos.

max_distance

Numeric. The maximum allowable distance for fuzzy matching, which can either be a proportion (0 < max_distance < 1) or an integer representing the maximum number of allowed differences. Defaults to 0.1.

Details

The function performs the following steps:

  1. Validates the input, ensuring that splist is a character vector or a factor.

  2. Standardizes species names and identifies duplicate entries in the list.

  3. For each unique species name, it searches for matches in the dataset using approximate string matching (agrep), with a customizable max_distance.

  4. Retrieves the taxonomic and common name data for the closest matching species.

If no matches are found for a species, the corresponding row in the output will contain NA values.

Value

A data frame with the following columns:

name_submitted

The species name provided as input.

accepted_name

The closest matching species name from the dataset, or NA if no match is found.

order_name

The taxonomic order of the species.

family_name

The taxonomic family of the species.

english_name

The common name of the species in English.

spanish_name

The common name of the species in Spanish.

status

The conservation or other status of the species.

dist

The computed distance between the submitted name and the matched name.

Examples

# Example: Search for bird species in the dataset
splist <- c("Falco sparverius", "Tinamus osgodi", "Crypturellus soui",
            "Thraupis palmarum", "Thamnophilus praecox")
search_avesperu(splist)


avesperu documentation built on Aug. 8, 2025, 7:49 p.m.