Introduction to reptiledbr: Accessing The Reptile Database in R

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(reptiledbr)

reptiledbr is an R package that provides an interface to The Reptile Database, allowing researchers and reptile enthusiasts to easily access taxonomic information, distribution data, and other details about reptile species. This tutorial will walk you through the basic usage of the package.

Installation

You can install the reptiledbr package from GitHub using:

# install.packages("pak")
pak::pak("PaulESantos/reptiledbr")

Basic Usage

1. Loading the package

Let's start by loading the package:

library(reptiledbr)

2. Retrieving data for specific species

The main function of the package is get_reptiledb_data(), which allows you to search for one or more species:

# Create a list of species to search
species_list <- c(
  "Lachesis muta",
  "Python bivittatus",
  "Crotalus atrox"
)

This function will connect to The Reptile Database, search for each species, and download the available information. During the process, you'll see progress messages like:

# Get data for these species
reptile_data <- get_reptiledb_data(species_list)

3. Understanding the returned data

The get_reptiledb_data() function returns a tibble with columns containing both metadata about the search and the actual data retrieved:

reptile_data

The data column contains nested tibbles with all the information scraped from each species page.

4. Formatting data with specialized functions

reptiledbr provides several specialized functions to extract and format specific types of information:

Synonyms

format_synonyms(reptile_data)

Distribution information

format_distribution(reptile_data)

Higher taxonomic classifications

format_higher_taxa(reptile_data)

Subspecies information

format_subspecies(reptile_data)

Common names

format_common_names(reptile_data)

Reproduction information

format_reproduction(reptile_data)

Type specimens

format_types(reptile_data)

Diagnosis information

format_diagnosis(reptile_data)

Comments

format_comments(reptile_data)

Etymology

format_etymology(reptile_data)

References

format_references(reptile_data)

Handling Special Cases

The package provides proper error handling for various cases:

1. Trinomial names (subspecies)

If you search for a trinomial name (genus + species + subspecies), the package will issue a warning and skip the search:

species_list <- c(
  "Lachesis muta",
  "Bothrops atrox insularis"  # Trinomial name
)
reptile_data <- get_reptiledb_data(species_list)

2. Incomplete species names

The package can also handle incomplete species names, but it will warn you if no data is found:

species_list <- c(
  "Lachesis muta",
  "Lachesis sp"  # Incomplete species name
)
reptile_data <- get_reptiledb_data(species_list)

Conclusion

reptiledbr provides an easy and structured way to access reptile species information from The Reptile Database. The package handles many common edge cases and provides specialized functions to extract and format specific types of information. This makes it a valuable tool for herpetologists, ecologists, and other researchers working with reptile data.

For more information about the package, including advanced usage and complete function documentation, please refer to the package's documentation.



Try the reptiledbr package in your browser

Any scripts or data that you put into this service are public.

reptiledbr documentation built on Aug. 8, 2025, 7:15 p.m.