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.
You can install the reptiledbr
package from GitHub using:
# install.packages("pak") pak::pak("PaulESantos/reptiledbr")
Let's start by loading the package:
library(reptiledbr)
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)
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.
reptiledbr
provides several specialized functions to extract and format specific types of information:
format_synonyms(reptile_data)
format_distribution(reptile_data)
format_higher_taxa(reptile_data)
format_subspecies(reptile_data)
format_common_names(reptile_data)
format_reproduction(reptile_data)
format_types(reptile_data)
format_diagnosis(reptile_data)
format_comments(reptile_data)
format_etymology(reptile_data)
format_references(reptile_data)
The package provides proper error handling for various cases:
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)
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)
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.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.