Getting started with sharkipediaR
Pablo Fuenzalida
2026-05-26
Source:vignettes/sharkipediar.Rmd
sharkipediar.RmdWhy this package exists
Sharkipedia is a curated,
open database of shark and ray life-history traits and population
abundance time series — the kind of comparative resource that underpins
fisheries assessment, extinction-risk analysis, and macroecology (Dulvy et al.,
2022). sharkipediaR brings those data into R as
tidy tibbles so your workflows look like any other modern ecological
analysis: %>% pipes, explicit
provenance, ggplot-ready tables, and interactive plotly
charts in the ecological vignette.
The package is deliberately not a bulk mirror of the website. It is a polite, reproducible client: rate-limited requests, in-session caching, and HTML parsing separated from cleaning and validation.
Installation
# install.packages("devtools")
devtools::install_github("ecologistpablo/SharkpediaR")
library(sharkipediaR)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, unionA thirty-second workflow
With an internet connection, you can pull data for a single species in three lines:
meta <- sp_species("Carcharhinus acronotus")
traits <- sp_traits("Carcharhinus acronotus")
trends <- sp_trends("Carcharhinus acronotus")Every user-facing table includes
source_url and
retrieved_at so you can cite exactly what
was downloaded and when — essential for Red List workshops, stock
assessments, and supplementary materials.
Offline example data
Vignettes and R CMD check use a frozen example dataset
so documentation builds without hitting the live site:
ex <- example_carcharhinus()
names(ex)
#> [1] "species_meta" "traits" "trends" "references"
#> [5] "species_index"| List element | Description |
|---|---|
species_meta |
Taxonomy + provenance (one row) |
traits |
Long-format life-history trait measurements |
trends |
Long-format population trend observations |
references |
Reference IDs linked from the species page |
species_index |
Sample rows from the public species index |
Exported functions at a glance
| Function | Script | Purpose |
|---|---|---|
sp_species_urls() |
R/sp_species_urls.R |
Discover species names and URLs from the index |
sp_search() |
R/sp_search.R |
Filter the index by partial scientific name |
sp_species() |
R/sp_species.R |
Taxonomy metadata for one species |
sp_traits() |
R/sp_traits.R |
Life-history traits (long format) |
sp_trends() |
R/sp_trends.R |
Population trends (long format) |
sp_references() |
R/sp_references.R |
Bibliographic reference links |
fetch_page() |
R/fetch.R |
Low-level HTML retrieval (advanced) |
example_carcharhinus() |
R/example_data.R |
Offline example data |
Internal parsing and cleaning live in R/parse.R,
R/clean.R, and R/validate.R — see the
Architecture and function reference vignette.
Where to go next
-
Ecological workflows — trait summaries, interactive
plotly trend plots,
%>%workflows. - Architecture and function reference — how every function in each script works, with pipeline examples.
Building the pkgdown site
install.packages(c("pkgdown", "ggplot2", "plotly", "htmltools"))
pkgdown::build_site()The site will include these vignettes under Articles automatically.