knitr::opts_chunk$set(collapse = TRUE,
                      comment = "#>",
                      eval = TRUE)
devtools::load_all()

Installing and loading the package:

devtools::install_github("liibre/Rocc")

library(Rocc)

This package downloads information from the speciesLink API. It generates the desired url and uses functions from jsonlite package to GET the url and save the output as a csv file. The speciesLink API is a courtesy of Sidnei de Souza from CRIA (Centro de Referência em Informação Ambiental) :)

See ?rspeciesLink for all search options. Bellow function's arguments.

args(rspeciesLink)

Example 1: basic search

Search for records of Eugenia platyphylla and Chaetocalyx acutifolia in speciesLink API. Same as: http://api.splink.org.br/records/ScientificName/Eugenia%20platyphylla/Chaetocalyx%20acutifolia/scope/plants

sp1 <- "Eugenia platyphylla"
sp2 <- "Chaetocalyx acutifolia"

Setting scope "plants".

ex01 <- rspeciesLink(filename = "ex01",
                     species =  c(sp1, sp2),
                     Scope = "plants")

Checking search output.

head(ex01$data)
dim(ex01$data)
str(ex01$data)

Checking if required species are in the output.

# are required species in the output
## list species in the output
ex01.sp <- unique(ex01$data$scientificName)
## check if species are in the output - yes!
c(sp1, sp2) %in% ex01.sp

Checking colnames in data output.

names(ex01$data)
knitr::kable(data.frame(columns = sort(names(ex01$data))))

Example 2: specifying collection of origin and specimens with image

Search for Rauvolfia selowii and Cantinoa althaeifolia. Now using collectioncode and Images arguments.

Same as: http://api.splink.org.br/records/CollectionCode/uec/scientificname/Rauvolfia%20sellowii/Cantinoa%20althaeifolia/Images/yes

ex02 <- rspeciesLink(filename = "ex02",
                     collectionCode = "uec",
                     species = c("Rauvolfia sellowii", 
                                        "Cantinoa althaeifolia"),
                     Images = "Yes")

Checking again if species are in the search.

# again species are in the output
c("Rauvolfia sellowii", "Cantinoa althaeifolia") %in% ex02$data$scientificName

Checking url used in the search.

ex02$url
# check output
head(ex02$data)
dim(ex02$data)
str(ex02$data)

Is data only from UEC collection?

# check fiel collectioncode
unique(ex02$data$collectionCode)

Example 3: testing coordinates quality selection

For species Tillandsia stricta.

ex03 <- rspeciesLink(filename = "ex03",
                     species = "Tillandsia stricta",
                     Coordinates = "Yes",
                     CoordinatesQuality = "Good")

Checking if species is in the output.

"Tillandsia stricta"%in%ex03$data$scientificName

Checking url and output.

ex03$url
# output check
dim(ex03$data) # 1623
head(ex03$data)

Now with another selection of coordinate quality.

# another selection of coordinates quality
ex03b <- rspeciesLink(filename = "ex03b",
                      species = "Tillandsia stricta")
                   #coordinatesQuality = "Bad")

Checking url and output.

ex03b$url
# check output
dim(ex03b$data) # 1762
head(ex03b$data)

Example 4: Only plant species in IUCN Red List in a particular geographic area

This example searches for 100 herbarium plants collected in Mariana county (Minas Gerais state, Brazil) that are in the IUCN Red List.

ex04 <- rspeciesLink(filename = "ex04",
                     Scope = "plants", 
                     basisOfRecord = "PreservedSpecimen",
                     county = "Mariana", 
                     stateProvince = c("Minas Gerais", "MG"),
                     country = c("Brazil", "Brasil"),
                     RedList = TRUE,
                     MaxRecords = 100)
dim(ex04$data)

Example 5:

Checks for synonyms on Flora do Brasil 2020, the official plant list for taxonomic nomenclature.

ex05 <- rspeciesLink(filename = "ex05",
                     species = "Tillandsia stricta", 
                     Synonyms = "flora2020")

There is a limit of nine species for requiring to check for synonyms. If the lenght of species name vector is > 9, function stops.

tensp <- c(
  "Tillandsia stricta", "Rauvolfia sellowii", "Cantinoa althaeifolia",
  "Eugenia platyphylla","Chaetocalyx acutifolia", "Asplenium serra", 
  "Asplenium truncorum", "Prepusa montana", "Ocotea catharinensis",
  "Asplenium triquetrum"
            )

Function stops if argument Synonyms is used with more than nine species. If

ex05 <- rspeciesLink(filename = "ex05",
                     species = tensp, 
                     Synonyms = "flora2020")

Returns error:

Function does not support synonym check of more than nine species

General check

Checking if files were written on disk

Listing files on list.

resu <- list.files("results", pattern = '.csv', full.names = TRUE)

All outputs are readable.

all.resu <- lapply(resu, read.csv)


saramortara/rocc documentation built on April 3, 2022, 3:41 p.m.