Search for Bird Species Data in the Birds of Peru Dataset
Source:R/get_avesperu.R
search_avesperu.Rd
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.
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.
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.
Details
The function performs the following steps:
Validates the input, ensuring that
splist
is a character vector or a factor.Standardizes species names and identifies duplicate entries in the list.
For each unique species name, it searches for matches in the dataset using approximate string matching (
agrep
), with a customizablemax_distance
.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.
Examples
# Example: Search for bird species in the dataset
splist <- c("Falco sparverius", "Tinamus osgodi", "Crypturellus soui",
"Thraupis palmarum", "Thamnophilus praecox")
search_avesperu(splist)
#> name_submitted accepted_name order_name family_name
#> 1 Falco sparverius Falco sparverius Falconiformes Falconidae
#> 2 Tinamus osgodi Tinamus osgoodi Tinamiformes Tinamidae
#> 3 Crypturellus soui Crypturellus soui Tinamiformes Tinamidae
#> 4 Thraupis palmarum Thraupis palmarum Passeridae Thraupidae
#> 5 Thamnophilus praecox Thamnophilus praecox Passeriformes Thamnophilidae
#> english_name spanish_name status dist
#> 1 American Kestrel Cernícalo Americano Residente 0
#> 2 Black Tinamou Perdiz Negra Residente 1
#> 3 Little Tinamou Perdiz Chica Residente 0
#> 4 Palm Tanager Tangara de Palmeras Residente 0
#> 5 Cocha Antshrike Batará de Cocha Residente 0