Installing and loading the package:

devtools::install_github("liibre/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)
#> function (dir = "results/", filename = "output", save = TRUE, 
#>     basisOfRecord = NULL, species = NULL, collectionCode = NULL, 
#>     country = NULL, stateProvince = NULL, county = NULL, Coordinates = NULL, 
#>     CoordinatesQuality = NULL, Scope = NULL, Synonyms = "no synomyms", 
#>     Typus = FALSE, Images = NULL, RedList = FALSE, MaxRecords = NULL) 
#> NULL

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")
#> Making request to speciesLink...
#> Writing results/ex02.csv on disk.

Checking again if species are in the search.

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

Checking url used in the search.

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

Is data only from UEC collection?

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

Example 3: testing coordinates quality selection

For species Tillandsia stricta.

ex03 <- rspeciesLink(filename = "ex03",
                     species = "Tillandsia stricta",
                     Coordinates = "Yes",
                     CoordinatesQuality = "Good")
#> Making request to speciesLink...
#> Writing results/ex03.csv on disk.

Checking if species is in the output.

"Tillandsia stricta"%in%ex03$data$scientificName
#> [1] FALSE

Checking url and output.

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

Now with another selection of coordinate quality.

# another selection of coordinates quality
ex03b <- rspeciesLink(filename = "ex03b",
                      species = "Tillandsia stricta")
#> Making request to speciesLink...
#> Writing results/ex03b.csv on disk.
                   #coordinatesQuality = "Bad")

Checking url and output.

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

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)
#> Making request to speciesLink...
#> Writing results/ex04.csv on disk.
dim(ex04$data)
#> NULL

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")
#> Making request to speciesLink...
#> Writing results/ex05.csv on disk.

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)