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)
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))))
Search for Rauvolfia selowii and Cantinoa althaeifolia. Now using collectioncode
and Images
arguments.
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)
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)
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)
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
Listing files on list.
resu <- list.files("results", pattern = '.csv', full.names = TRUE)
All outputs are readable.
all.resu <- lapply(resu, read.csv)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.