Local Taxonomic Searches with reptiledbr

Introduction

The reptiledbr package allows users to access taxonomic information of reptiles directly from R without the constant need to make web queries to The Reptile Database server. This provides several advantages:

This vignette demonstrates how to perform local searches using the package’s main functions.

Main Functions for Local Searches

The reptiledbr package offers three key functions for performing local taxonomic searches:

  1. reptiledbr_exact(): For exact searches of scientific names
  2. reptiledbr_partial(): For searches that allow partial matches (fuzzy matching)
  3. search_reptiledbr(): Flexible function that combines exact and partial search capabilities
  4. list_subspecies_reptiledbr(): To obtain information about subspecies

Practical Examples

Exact Search for Species Names

The reptiledbr_exact() function verifies if the provided species names exist exactly as written in the database. This function is useful when you need to verify the validity of specific taxonomic names.

library(reptiledbr)

# Define a vector of species names to search
species_names <- c(
  "Lachesis muta",
  "Python bivittatus",
  "Crotalus atrox",
  "Bothrops atrox insularis", # Trinomial (with subspecies) - will generate an error
  "Lachesis sp",
  "Crotalus atroxx", # Intentional typo
  "Anolis liogaster",
  "Lachesis mutta", # Intentional typo
  "Python bivitatus" # Intentional typo
)

# Perform exact search
reptiledbr_exact(species_names)
#> # A tibble: 9 × 10
#>      id input_name found species_match order family genus epithet author message
#>   <int> <chr>      <lgl> <chr>         <fct> <fct>  <fct> <fct>   <chr>  <chr>  
#> 1     1 Lachesis … TRUE  Lachesis muta Serp… Viper… Lach… muta    Linna… No sub…
#> 2     2 Python bi… TRUE  Python bivit… Serp… Pytho… Pyth… bivitt… Kuhl … Specie…
#> 3     3 Crotalus … TRUE  Crotalus atr… Serp… Viper… Crot… atrox   Baird… No sub…
#> 4     4 Bothrops … FALSE <NA>          <NA>  <NA>   <NA>  <NA>    <NA>   Specie…
#> 5     5 Lachesis … FALSE <NA>          <NA>  <NA>   <NA>  <NA>    <NA>   Specie…
#> 6     6 Crotalus … FALSE <NA>          <NA>  <NA>   <NA>  <NA>    <NA>   Specie…
#> 7     7 Anolis li… TRUE  Anolis lioga… Saur… Anoli… Anol… liogas… Boule… No sub…
#> 8     8 Lachesis … FALSE <NA>          <NA>  <NA>   <NA>  <NA>    <NA>   Specie…
#> 9     9 Python bi… FALSE <NA>          <NA>  <NA>   <NA>  <NA>    <NA>   Specie…

As can be observed, the exact search only returns matches for names that are correctly written. Names with typos or incorrect formats (such as trinomials) are not recognized.

Flexible Search with Additional Options

The search_reptiledbr() function offers greater flexibility, allowing you to specify whether to use partial matching or not:

# Define a list of valid species
subspecies_names <- c("Lachesis muta", 
                     "Anilius scytale",
                     "Anolis bahorucoensis",
                     "Anolis baleatus",
                     "Crotalus atrox",
                     "Anolis barahonae",
                     "Anolis bremeri")

# Exact search (without fuzzy matching)
search_reptiledbr(subspecies_names, use_fuzzy = FALSE)
#> # A tibble: 7 × 12
#>      id input_name found species_match order family genus epithet author message
#>   <int> <chr>      <lgl> <chr>         <fct> <fct>  <fct> <fct>   <chr>  <chr>  
#> 1     1 Lachesis … TRUE  Lachesis muta Serp… Viper… Lach… muta    Linna… No sub…
#> 2     2 Anilius s… TRUE  Anilius scyt… Serp… Anili… Anil… scytale Linna… Specie…
#> 3     3 Anolis ba… TRUE  Anolis bahor… Saur… Anoli… Anol… bahoru… Noble… Specie…
#> 4     4 Anolis ba… TRUE  Anolis balea… Saur… Anoli… Anol… baleat… Cope … Specie…
#> 5     5 Crotalus … TRUE  Crotalus atr… Serp… Viper… Crot… atrox   Baird… No sub…
#> 6     6 Anolis ba… TRUE  Anolis barah… Saur… Anoli… Anol… baraho… Willi… Specie…
#> 7     7 Anolis br… TRUE  Anolis breme… Saur… Anoli… Anol… bremeri Barbo… Specie…
#> # ℹ 2 more variables: match_type <chr>, fuzzy_match <lgl>

Obtaining Subspecies Information

A particularly useful feature is the ability to list all recognized subspecies for a given species using list_subspecies_reptiledbr():

# List all subspecies for the found species
search_reptiledbr(subspecies_names, use_fuzzy = FALSE) |> 
  list_subspecies_reptiledbr()
#> # A tibble: 20 × 3
#>    species              subspecies_name                    author               
#>    <chr>                <chr>                              <chr>                
#>  1 Anilius scytale      Anilius scytale phelpsorum         Roze 1958            
#>  2 Anilius scytale      Anilius scytale scytale            Linnaeus 1758        
#>  3 Anolis bahorucoensis Anolis bahorucoensis bahorucoensis Noble & Hassler 1933 
#>  4 Anolis bahorucoensis Anolis bahorucoensis southerlandi  Schwartz 1978        
#>  5 Anolis baleatus      Anolis baleatus baleatus           Cope 1864            
#>  6 Anolis baleatus      Anolis baleatus altager            Schwartz 1975        
#>  7 Anolis baleatus      Anolis baleatus caeruleolatus      Schwartz 1974        
#>  8 Anolis baleatus      Anolis baleatus fraudator          Schwartz 1974        
#>  9 Anolis baleatus      Anolis baleatus lineatacervix      Schwartz 1978        
#> 10 Anolis baleatus      Anolis baleatus litorisilva        Schwartz 1974        
#> 11 Anolis baleatus      Anolis baleatus multistruppus      Schwartz 1974        
#> 12 Anolis baleatus      Anolis baleatus samanae            Schwartz 1974        
#> 13 Anolis baleatus      Anolis baleatus scelestus          Schwartz 1974        
#> 14 Anolis baleatus      Anolis baleatus sublimis           Schwartz 1974        
#> 15 Anolis barahonae     Anolis barahonae barahonae         Williams 1962        
#> 16 Anolis barahonae     Anolis barahonae albocellatus      Schwartz 1974        
#> 17 Anolis barahonae     Anolis barahonae ininquinatus      Cullom & Schwartz 19…
#> 18 Anolis barahonae     Anolis barahonae mulitus           Cullom & Schwartz 19…
#> 19 Anolis bremeri       Anolis bremeri bremeri             Barbour 1914         
#> 20 Anolis bremeri       Anolis bremeri insulaepinorum      Garrido 1972

We can also combine partial matching search and subspecies retrieval:

# Partial matching search followed by subspecies listing
reptiledbr_partial(c("Lachesis mutta", 
                    "Python bivitatus",
                    "Anolis barahonae")) |> 
  list_subspecies_reptiledbr()
#> # A tibble: 6 × 3
#>   species           subspecies_name               author                     
#>   <chr>             <chr>                         <chr>                      
#> 1 Anolis barahonae  Anolis barahonae barahonae    Williams 1962              
#> 2 Anolis barahonae  Anolis barahonae albocellatus Schwartz 1974              
#> 3 Anolis barahonae  Anolis barahonae ininquinatus Cullom & Schwartz 1980     
#> 4 Anolis barahonae  Anolis barahonae mulitus      Cullom & Schwartz 1980     
#> 5 Python bivittatus Python bivittatus progschai   Jacobs, Aulyia & Böhme 2009
#> 6 Python bivittatus Python bivittatus bivittatus  Kuhl 1820

Conclusions

The reptiledbr package provides efficient tools for verifying and obtaining taxonomic information about reptiles without the need to make constant queries to The Reptile Database serverusing reptiledbr::search_reptiledbr(). This greatly facilitates working with large datasets and allows for consistent taxonomic verification even without an internet connection.

The local search functions are particularly useful for researchers and professionals working with herpetological data, enabling efficient cleaning and validation of species lists, identification of common typos, and access to up-to-date taxonomic information about reptiles.