diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..5eb0a05 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,9 @@ +^.*\.Rproj$ +^\.Rproj\.user$ +^CONDUCT\.md$ +README.Rmd +.travis.yml +appveyor.yml +cran-comments.md +NEWS.md +man-roxygen diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..efa7774 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.Rproj.user +.Rhistory +.RData +oldtravis.yml + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cacf54b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: r +notifications: + email: + on_success: change + on_failure: change diff --git a/CONDUCT.md b/CONDUCT.md new file mode 100644 index 0000000..52a673e --- /dev/null +++ b/CONDUCT.md @@ -0,0 +1,25 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, we pledge to respect all people who +contribute through reporting issues, posting feature requests, updating documentation, +submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for +everyone, regardless of level of experience, gender, gender identity and expression, +sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. + +Examples of unacceptable behavior by participants include the use of sexual language or +imagery, derogatory comments or personal attacks, trolling, public or private harassment, +insults, or other unprofessional conduct. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, +commits, code, wiki edits, issues, and other contributions that are not aligned to this +Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed +from the project team. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by +opening an issue or contacting one or more of the project maintainers. + +This Code of Conduct is adapted from the Contributor Covenant +(http:contributor-covenant.org), version 1.0.0, available at +http://contributor-covenant.org/version/1/0/0/ diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..2b3ed8f --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,17 @@ +Package: rredlist +Type: Package +Title: IUCN Red List Client +Description: IUCN Red List client. Functions for fetching data and stuff. +Version: 0.0.4.9300 +Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"), + email = "myrmecocystus@gmail.com")) +License: MIT + file LICENSE +URL: https://github.com/ropenscilabs/rredlist +BugReports: https://github.com/ropenscilabs/rredlist/issues +LazyData: TRUE +Imports: + httr, + jsonlite +Suggests: + testthat +RoxygenNote: 5.0.1 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bc67dd4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +YEAR: 2015 +COPYRIGHT HOLDER: Scott Chamberlain diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..23497aa --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,32 @@ +# Generated by roxygen2: do not edit by hand + +export(rl_common_names) +export(rl_common_names_) +export(rl_countries) +export(rl_countries_) +export(rl_habitats) +export(rl_habitats_) +export(rl_measures) +export(rl_measures_) +export(rl_narrative) +export(rl_narrative_) +export(rl_regions) +export(rl_regions_) +export(rl_search) +export(rl_search_) +export(rl_sp) +export(rl_sp_) +export(rl_sp_category) +export(rl_sp_category_) +export(rl_sp_citation) +export(rl_sp_citation_) +export(rl_sp_count) +export(rl_sp_count_) +export(rl_sp_country) +export(rl_sp_country_) +export(rl_synonyms) +export(rl_synonyms_) +export(rl_threats) +export(rl_threats_) +import(httr) +import(jsonlite) diff --git a/R/rl_common_names.R b/R/rl_common_names.R new file mode 100644 index 0000000..365ea04 --- /dev/null +++ b/R/rl_common_names.R @@ -0,0 +1,19 @@ +#' Get species narrative information by taxon name or IUCN id +#' +#' @export +#' @param name (character) Binomial taxonomic name +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_common_names('Loxodonta africana') +#' rl_common_names_('Loxodonta africana') +#' } +rl_common_names <- function(name = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(file.path("species/common_names", name), key, ...), parse) +} + +#' @export +#' @rdname rl_common_names +rl_common_names_ <- function(name = NULL, key = NULL, ...) { + rr_GET(file.path("species/common_names", name), key, ...) +} diff --git a/R/rl_countries.R b/R/rl_countries.R new file mode 100644 index 0000000..bee4812 --- /dev/null +++ b/R/rl_countries.R @@ -0,0 +1,18 @@ +#' Get countries +#' +#' @export +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_countries() +#' rl_countries_() +#' } +rl_countries <- function(key = NULL, parse = FALSE, ...) { + rl_parse(rr_GET("country/list", key, ...), parse) +} + +#' @export +#' @rdname rl_countries +rl_countries_ <- function(key = NULL, ...) { + rr_GET("country/list", key, ...) +} diff --git a/R/rl_habitats.R b/R/rl_habitats.R new file mode 100644 index 0000000..377a8ae --- /dev/null +++ b/R/rl_habitats.R @@ -0,0 +1,37 @@ +#' Get species habitats by taxon name or IUCN id +#' +#' @export +#' @template commonargs +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_habitats('Fratercula arctica') +#' rl_habitats('Fratercula arctica', region = 'europe') +#' rl_habitats(id = 12392) +#' rl_habitats(id = 22694927, region = 'europe') +#' +#' rl_habitats_('Fratercula arctica') +#' rl_habitats_(id = 12392) +#' } +rl_habitats <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(.habitats(name, id, region), key, ...), parse) +} + +#' @export +#' @rdname rl_habitats +rl_habitats_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { + rr_GET(.habitats(name, id, region), key, ...) +} + +.habitats <- function(name = NULL, id = NULL, region = NULL) { + stopifnot(xor(!is.null(name), !is.null(id))) + path <- if (!is.null(name)) { + file.path("habitats/species/name", name) + } else { + file.path("habitats/species/id", id) + } + if (!is.null(region)) { + path <- file.path(path, "region", region) + } + path +} diff --git a/R/rl_measures.R b/R/rl_measures.R new file mode 100644 index 0000000..859f97c --- /dev/null +++ b/R/rl_measures.R @@ -0,0 +1,37 @@ +#' Get species conservation measures by taxon name or IUCN id +#' +#' @export +#' @template commonargs +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_measures('Fratercula arctica') +#' rl_measures('Fratercula arctica', region = 'europe') +#' rl_measures(id = 12392) +#' rl_measures(id = 22694927, region = 'europe') +#' +#' rl_measures_('Fratercula arctica') +#' rl_measures_(id = 22694927, region = 'europe') +#' } +rl_measures <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(.measures(name, id, region), key, ...), parse) +} + +#' @export +#' @rdname rl_measures +rl_measures_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { + rr_GET(.measures(name, id, region), key, ...) +} + +.measures <- function(name = NULL, id = NULL, region = NULL) { + stopifnot(xor(!is.null(name), !is.null(id))) + path <- if (!is.null(name)) { + file.path("measures/species/name", name) + } else { + file.path("measures/species/id", id) + } + if (!is.null(region)) { + path <- file.path(path, "region", region) + } + path +} diff --git a/R/rl_narrative.R b/R/rl_narrative.R new file mode 100644 index 0000000..d6870f9 --- /dev/null +++ b/R/rl_narrative.R @@ -0,0 +1,37 @@ +#' Get species narrative information by taxon name or IUCN id +#' +#' @export +#' @template commonargs +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_narrative('Fratercula arctica') +#' rl_narrative('Fratercula arctica', region = 'europe') +#' rl_narrative(id = 12392) +#' rl_narrative(id = 22694927, region = 'europe') +#' +#' rl_narrative_('Fratercula arctica') +#' rl_narrative_('Fratercula arctica', region = 'europe') +#' } +rl_narrative <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(.narrative(name, id, region), key, ...), parse) +} + +#' @export +#' @rdname rl_narrative +rl_narrative_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { + rr_GET(.narrative(name, id, region), key, ...) +} + +.narrative <- function(name = NULL, id = NULL, region = NULL) { + stopifnot(xor(!is.null(name), !is.null(id))) + path <- if (!is.null(name)) { + file.path("species/narrative", name) + } else { + file.path("species/narrative/id", id) + } + if (!is.null(region)) { + path <- file.path(path, "region", region) + } + path +} diff --git a/R/rl_regions.R b/R/rl_regions.R new file mode 100644 index 0000000..492e973 --- /dev/null +++ b/R/rl_regions.R @@ -0,0 +1,19 @@ +#' Get regions +#' +#' @export +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_regions() +#' rl_regions(parse = FALSE) +#' rl_regions_() +#' } +rl_regions <- function(key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET("region/list", key, ...), parse) +} + +#' @export +#' @rdname rl_regions +rl_regions_ <- function(key = NULL, ...) { + rr_GET("region/list", key, ...) +} diff --git a/R/rl_search.R b/R/rl_search.R new file mode 100644 index 0000000..4af072a --- /dev/null +++ b/R/rl_search.R @@ -0,0 +1,38 @@ +#' Search by taxon name or IUCN id +#' +#' @export +#' @template commonargs +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_search('Fratercula arctica') +#' rl_search('Fratercula arctica', region = 'europe') +#' rl_search(id = 12392) +#' rl_search(id = 22694927, region = 'europe') +#' +#' rl_search('Fratercula arctica', parse = FALSE) +#' rl_search_('Fratercula arctica') +#' rl_search_('Fratercula arctica', region = 'europe') +#' } +rl_search <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(.search(name, id, region), key, ...), parse) +} + +#' @export +#' @rdname rl_search +rl_search_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { + rr_GET(.search(name, id, region), key, ...) +} + +.search <- function(name = NULL, id = NULL, region = NULL) { + stopifnot(xor(!is.null(name), !is.null(id))) + path <- if (!is.null(name)) { + file.path("species", name) + } else { + file.path("species/id", id) + } + if (!is.null(region)) { + path <- file.path(path, "region", region) + } + path +} diff --git a/R/rl_sp.R b/R/rl_sp.R new file mode 100644 index 0000000..a544885 --- /dev/null +++ b/R/rl_sp.R @@ -0,0 +1,21 @@ +#' Get species +#' +#' @export +#' @param page (interger) Page to get. Default: 1 +#' @template all +#' @examples \dontrun{ +#' rl_sp(page = 1) +#' rl_sp(page = 2) +#' rl_sp(page = 3) +#' rl_sp(page = 3, parse = FALSE) +#' rl_sp_(page = 3) +#' } +rl_sp <- function(page, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(file.path("species/page", page), key, ...), parse) +} + +#' @export +#' @rdname rl_sp +rl_sp_ <- function(page, key = NULL, ...) { + rr_GET(file.path("species/page", page), key, ...) +} \ No newline at end of file diff --git a/R/rl_sp_category.R b/R/rl_sp_category.R new file mode 100644 index 0000000..0146253 --- /dev/null +++ b/R/rl_sp_category.R @@ -0,0 +1,21 @@ +#' Get species by category +#' +#' @export +#' @param category (character) 2 letter category code +#' @template all +#' @examples \dontrun{ +#' rl_sp_category('VU') +#' rl_sp_category('EN') +#' rl_sp_category('EX') +#' rl_sp_category('EX', parse = FALSE) +#' rl_sp_category_('EX') +#' } +rl_sp_category <- function(category, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(file.path("species/category", category), key, ...), parse) +} + +#' @export +#' @rdname rl_sp_category +rl_sp_category_ <- function(category, key = NULL, parse = TRUE, ...) { + rr_GET(file.path("species/category", category), key, ...) +} diff --git a/R/rl_sp_citation.R b/R/rl_sp_citation.R new file mode 100644 index 0000000..16f4e49 --- /dev/null +++ b/R/rl_sp_citation.R @@ -0,0 +1,37 @@ +#' Get citations +#' +#' @export +#' @template commonargs +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_sp_citation('Balaena mysticetus') +#' rl_sp_citation('Balaena mysticetus', region = 'europe') +#' rl_sp_citation(id = 12392) +#' +#' rl_sp_citation(id = 2467, region = 'europe') +#' rl_sp_citation(id = 2467, region = 'europe', parse = FALSE) +#' rl_sp_citation_(id = 2467, region = 'europe') +#' } +rl_sp_citation <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(.sp_citation(name, id, region), key, ...), parse) +} + +#' @export +#' @rdname rl_sp_citation +rl_sp_citation_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { + rr_GET(.sp_citation(name, id, region), key, ...) +} + +.sp_citation <- function(name = NULL, id = NULL, region = NULL) { + stopifnot(xor(!is.null(name), !is.null(id))) + path <- if (!is.null(name)) { + file.path("species/citation", name) + } else { + file.path("species/citation/id", id) + } + if (!is.null(region)) { + path <- file.path(path, "region", region) + } + path +} diff --git a/R/rl_sp_count.R b/R/rl_sp_count.R new file mode 100644 index 0000000..c64bba9 --- /dev/null +++ b/R/rl_sp_count.R @@ -0,0 +1,19 @@ +#' Species count +#' +#' @export +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_sp_count() +#' rl_sp_count_() +#' } +rl_sp_count <- function(key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET("speciescount", key, ...), parse) +} + + +#' @export +#' @rdname rl_sp_count +rl_sp_count_ <- function(key = NULL, ...) { + rr_GET("speciescount", key, ...) +} diff --git a/R/rl_sp_country.R b/R/rl_sp_country.R new file mode 100644 index 0000000..955cf73 --- /dev/null +++ b/R/rl_sp_country.R @@ -0,0 +1,28 @@ +#' Get species by country +#' +#' @export +#' @param country (character) Country 2 letter character code +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_sp_country('AZ') +#' rl_sp_country('NZ') +#' +#' # don't parse to data.frame, gives list +#' rl_sp_country('NZ', parse = FALSE) +#' # don't parse at all, get json back +#' rl_sp_country_('NZ') +#' +#' # curl options +#' library("httr") +#' res <- rl_sp_country('NZ', config=verbose()) +#' } +rl_sp_country <- function(country, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(file.path("country/getspecies", country), key, ...), parse) +} + +#' @export +#' @rdname rl_sp_country +rl_sp_country_ <- function(country, key = NULL, ...) { + rr_GET(file.path("country/getspecies", country), key, ...) +} diff --git a/R/rl_synonyms.R b/R/rl_synonyms.R new file mode 100644 index 0000000..427e7a4 --- /dev/null +++ b/R/rl_synonyms.R @@ -0,0 +1,20 @@ +#' Get species narrative information by taxon name or IUCN id +#' +#' @export +#' @param name (character) Binomial taxonomic name +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_synonyms('Loxodonta africana') +#' rl_synonyms('Loxodonta africana', parse = FALSE) +#' rl_synonyms_('Loxodonta africana') +#' } +rl_synonyms <- function(name = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(file.path("species/synonym", name), key, ...), parse) +} + +#' @export +#' @rdname rl_synonyms +rl_synonyms_ <- function(name = NULL, key = NULL, ...) { + rr_GET(file.path("species/synonym", name), key, ...) +} diff --git a/R/rl_threats.R b/R/rl_threats.R new file mode 100644 index 0000000..0175664 --- /dev/null +++ b/R/rl_threats.R @@ -0,0 +1,35 @@ +#' Get species threats by taxon name or IUCN id +#' +#' @export +#' @template commonargs +#' @template all +#' @template info +#' @examples \dontrun{ +#' rl_threats('Fratercula arctica') +#' rl_threats('Fratercula arctica', region = 'europe') +#' rl_threats(id = 12392) +#' rl_threats(id = 22694927, region = 'europe') +#' rl_threats_('Fratercula arctica') +#' } +rl_threats <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { + rl_parse(rr_GET(.threats(name, id, region), key, ...), parse) +} + +#' @export +#' @rdname rl_threats +rl_threats_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { + rr_GET(.threats(name, id, region), key, ...) +} + +.threats <- function(name = NULL, id = NULL, region = NULL) { + stopifnot(xor(!is.null(name), !is.null(id))) + path <- if (!is.null(name)) { + file.path("threats/species/name", name) + } else { + file.path("threats/species/id", id) + } + if (!is.null(region)) { + path <- file.path(path, "region", region) + } + path +} diff --git a/R/rredlist-package.R b/R/rredlist-package.R new file mode 100644 index 0000000..f63845c --- /dev/null +++ b/R/rredlist-package.R @@ -0,0 +1,8 @@ +#' rredlist +#' +#' @import httr jsonlite +#' @name rredlist-package +#' @aliases rredlist +#' @docType package +#' @keywords package +NULL diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..c33196f --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,23 @@ +ct <- function(l) Filter(Negate(is.null), l) + +rr_GET <- function(path, key, ...){ + temp <- GET(file.path(rr_base(), path), query = ct(list(token = check_key(key))), ...) + stop_for_status(temp) + stopifnot(temp$headers$`content-type` == 'application/json; charset=utf-8') + content(temp, as = 'text', encoding = "UTF-8") +} + +rl_parse <- function(x, parse) { + jsonlite::fromJSON(x, parse) +} + +check_key <- function(x){ + tmp <- if (is.null(x)) Sys.getenv("IUCN_REDLIST_KEY", "") else x + if (tmp == "") { + getOption("iucn_redlist_key", stop("need an API key for NOAA data", call. = FALSE)) + } else { + tmp + } +} + +rr_base <- function() "http://apiv3.iucnredlist.org/api/v3" diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..feb18a4 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,33 @@ +scrubr +====== + +```{r echo=FALSE} +knitr::opts_chunk$set( + warning = FALSE, + message = FALSE, + collapse = TRUE, + comment = "#>" +) +``` + +[![Build Status](https://travis-ci.org/ropenscilabs/rredlist.svg?branch=master)](https://travis-ci.org/ropenscilabs/rredlist) + +## Install + +```{r eval=FALSE} +devtools::install_github("ropenscilabs/rredlist") +``` + +```{r} +library("rredlist") +``` + +## xxx + +```{r} +"xxx" +``` + +## Meta + +* Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. diff --git a/man-roxygen/all.R b/man-roxygen/all.R new file mode 100644 index 0000000..69a8b30 --- /dev/null +++ b/man-roxygen/all.R @@ -0,0 +1,4 @@ +#' @param key A IUCN API token +#' @param ... Curl options passed to \code{\link[httr]{GET}} +#' @param parse (logical) Whether to parse to list (\code{FALSE}) or +#' data.frame (\code{TRUE}). Default: \code{TRUE} diff --git a/man-roxygen/commonargs.R b/man-roxygen/commonargs.R new file mode 100644 index 0000000..d27b094 --- /dev/null +++ b/man-roxygen/commonargs.R @@ -0,0 +1,3 @@ +#' @param name (character) Binomial taxonomic name +#' @param id (character) IUCN id +#' @param region (character) Binomial taxonomic name diff --git a/man-roxygen/info.R b/man-roxygen/info.R new file mode 100644 index 0000000..9d4cb96 --- /dev/null +++ b/man-roxygen/info.R @@ -0,0 +1,4 @@ +#' @return A list, with the data in the \code{result} slot, unless using +#' a function with a trailing underscore, in which case json as character +#' string is returned. +#' @references API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} diff --git a/man/rl_common_names.Rd b/man/rl_common_names.Rd new file mode 100644 index 0000000..0f533ae --- /dev/null +++ b/man/rl_common_names.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_common_names.R +\name{rl_common_names} +\alias{rl_common_names} +\alias{rl_common_names_} +\title{Get species narrative information by taxon name or IUCN id} +\usage{ +rl_common_names(name = NULL, key = NULL, parse = TRUE, ...) + +rl_common_names_(name = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get species narrative information by taxon name or IUCN id +} +\examples{ +\dontrun{ +rl_common_names('Loxodonta africana') +rl_common_names_('Loxodonta africana') +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_countries.Rd b/man/rl_countries.Rd new file mode 100644 index 0000000..4b17099 --- /dev/null +++ b/man/rl_countries.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_countries.R +\name{rl_countries} +\alias{rl_countries} +\alias{rl_countries_} +\title{Get countries} +\usage{ +rl_countries(key = NULL, parse = FALSE, ...) + +rl_countries_(key = NULL, ...) +} +\arguments{ +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get countries +} +\examples{ +\dontrun{ +rl_countries() +rl_countries_() +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_habitats.Rd b/man/rl_habitats.Rd new file mode 100644 index 0000000..6c2176d --- /dev/null +++ b/man/rl_habitats.Rd @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_habitats.R +\name{rl_habitats} +\alias{rl_habitats} +\alias{rl_habitats_} +\title{Get species habitats by taxon name or IUCN id} +\usage{ +rl_habitats(name = NULL, id = NULL, region = NULL, key = NULL, + parse = TRUE, ...) + +rl_habitats_(name = NULL, id = NULL, region = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{id}{(character) IUCN id} + +\item{region}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get species habitats by taxon name or IUCN id +} +\examples{ +\dontrun{ +rl_habitats('Fratercula arctica') +rl_habitats('Fratercula arctica', region = 'europe') +rl_habitats(id = 12392) +rl_habitats(id = 22694927, region = 'europe') + +rl_habitats_('Fratercula arctica') +rl_habitats_(id = 12392) +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_measures.Rd b/man/rl_measures.Rd new file mode 100644 index 0000000..53eff1d --- /dev/null +++ b/man/rl_measures.Rd @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_measures.R +\name{rl_measures} +\alias{rl_measures} +\alias{rl_measures_} +\title{Get species conservation measures by taxon name or IUCN id} +\usage{ +rl_measures(name = NULL, id = NULL, region = NULL, key = NULL, + parse = TRUE, ...) + +rl_measures_(name = NULL, id = NULL, region = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{id}{(character) IUCN id} + +\item{region}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get species conservation measures by taxon name or IUCN id +} +\examples{ +\dontrun{ +rl_measures('Fratercula arctica') +rl_measures('Fratercula arctica', region = 'europe') +rl_measures(id = 12392) +rl_measures(id = 22694927, region = 'europe') + +rl_measures_('Fratercula arctica') +rl_measures_(id = 22694927, region = 'europe') +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_narrative.Rd b/man/rl_narrative.Rd new file mode 100644 index 0000000..2214bc9 --- /dev/null +++ b/man/rl_narrative.Rd @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_narrative.R +\name{rl_narrative} +\alias{rl_narrative} +\alias{rl_narrative_} +\title{Get species narrative information by taxon name or IUCN id} +\usage{ +rl_narrative(name = NULL, id = NULL, region = NULL, key = NULL, + parse = TRUE, ...) + +rl_narrative_(name = NULL, id = NULL, region = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{id}{(character) IUCN id} + +\item{region}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get species narrative information by taxon name or IUCN id +} +\examples{ +\dontrun{ +rl_narrative('Fratercula arctica') +rl_narrative('Fratercula arctica', region = 'europe') +rl_narrative(id = 12392) +rl_narrative(id = 22694927, region = 'europe') + +rl_narrative_('Fratercula arctica') +rl_narrative_('Fratercula arctica', region = 'europe') +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_regions.Rd b/man/rl_regions.Rd new file mode 100644 index 0000000..082c603 --- /dev/null +++ b/man/rl_regions.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_regions.R +\name{rl_regions} +\alias{rl_regions} +\alias{rl_regions_} +\title{Get regions} +\usage{ +rl_regions(key = NULL, parse = TRUE, ...) + +rl_regions_(key = NULL, ...) +} +\arguments{ +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get regions +} +\examples{ +\dontrun{ +rl_regions() +rl_regions(parse = FALSE) +rl_regions_() +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_search.Rd b/man/rl_search.Rd new file mode 100644 index 0000000..e45db2f --- /dev/null +++ b/man/rl_search.Rd @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_search.R +\name{rl_search} +\alias{rl_search} +\alias{rl_search_} +\title{Search by taxon name or IUCN id} +\usage{ +rl_search(name = NULL, id = NULL, region = NULL, key = NULL, + parse = TRUE, ...) + +rl_search_(name = NULL, id = NULL, region = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{id}{(character) IUCN id} + +\item{region}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Search by taxon name or IUCN id +} +\examples{ +\dontrun{ +rl_search('Fratercula arctica') +rl_search('Fratercula arctica', region = 'europe') +rl_search(id = 12392) +rl_search(id = 22694927, region = 'europe') + +rl_search('Fratercula arctica', parse = FALSE) +rl_search_('Fratercula arctica') +rl_search_('Fratercula arctica', region = 'europe') +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_sp.Rd b/man/rl_sp.Rd new file mode 100644 index 0000000..4322acb --- /dev/null +++ b/man/rl_sp.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_sp.R +\name{rl_sp} +\alias{rl_sp} +\alias{rl_sp_} +\title{Get species} +\usage{ +rl_sp(page, key = NULL, parse = TRUE, ...) + +rl_sp_(page, key = NULL, ...) +} +\arguments{ +\item{page}{(interger) Page to get. Default: 1} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\description{ +Get species +} +\examples{ +\dontrun{ +rl_sp(page = 1) +rl_sp(page = 2) +rl_sp(page = 3) +rl_sp(page = 3, parse = FALSE) +rl_sp_(page = 3) +} +} + diff --git a/man/rl_sp_category.Rd b/man/rl_sp_category.Rd new file mode 100644 index 0000000..c295584 --- /dev/null +++ b/man/rl_sp_category.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_sp_category.R +\name{rl_sp_category} +\alias{rl_sp_category} +\alias{rl_sp_category_} +\title{Get species by category} +\usage{ +rl_sp_category(category, key = NULL, parse = TRUE, ...) + +rl_sp_category_(category, key = NULL, parse = TRUE, ...) +} +\arguments{ +\item{category}{(character) 2 letter category code} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\description{ +Get species by category +} +\examples{ +\dontrun{ +rl_sp_category('VU') +rl_sp_category('EN') +rl_sp_category('EX') +rl_sp_category('EX', parse = FALSE) +rl_sp_category_('EX') +} +} + diff --git a/man/rl_sp_citation.Rd b/man/rl_sp_citation.Rd new file mode 100644 index 0000000..d57b0f4 --- /dev/null +++ b/man/rl_sp_citation.Rd @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_sp_citation.R +\name{rl_sp_citation} +\alias{rl_sp_citation} +\alias{rl_sp_citation_} +\title{Get citations} +\usage{ +rl_sp_citation(name = NULL, id = NULL, region = NULL, key = NULL, + parse = TRUE, ...) + +rl_sp_citation_(name = NULL, id = NULL, region = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{id}{(character) IUCN id} + +\item{region}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get citations +} +\examples{ +\dontrun{ +rl_sp_citation('Balaena mysticetus') +rl_sp_citation('Balaena mysticetus', region = 'europe') +rl_sp_citation(id = 12392) + +rl_sp_citation(id = 2467, region = 'europe') +rl_sp_citation(id = 2467, region = 'europe', parse = FALSE) +rl_sp_citation_(id = 2467, region = 'europe') +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_sp_count.Rd b/man/rl_sp_count.Rd new file mode 100644 index 0000000..abdf289 --- /dev/null +++ b/man/rl_sp_count.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_sp_count.R +\name{rl_sp_count} +\alias{rl_sp_count} +\alias{rl_sp_count_} +\title{Species count} +\usage{ +rl_sp_count(key = NULL, parse = TRUE, ...) + +rl_sp_count_(key = NULL, ...) +} +\arguments{ +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Species count +} +\examples{ +\dontrun{ +rl_sp_count() +rl_sp_count_() +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_sp_country.Rd b/man/rl_sp_country.Rd new file mode 100644 index 0000000..25e994c --- /dev/null +++ b/man/rl_sp_country.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_sp_country.R +\name{rl_sp_country} +\alias{rl_sp_country} +\alias{rl_sp_country_} +\title{Get species by country} +\usage{ +rl_sp_country(country, key = NULL, parse = TRUE, ...) + +rl_sp_country_(country, key = NULL, ...) +} +\arguments{ +\item{country}{(character) Country 2 letter character code} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get species by country +} +\examples{ +\dontrun{ +rl_sp_country('AZ') +rl_sp_country('NZ') + +# don't parse to data.frame, gives list +rl_sp_country('NZ', parse = FALSE) +# don't parse at all, get json back +rl_sp_country_('NZ') + +# curl options +library("httr") +res <- rl_sp_country('NZ', config=verbose()) +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_synonyms.Rd b/man/rl_synonyms.Rd new file mode 100644 index 0000000..78adb93 --- /dev/null +++ b/man/rl_synonyms.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_synonyms.R +\name{rl_synonyms} +\alias{rl_synonyms} +\alias{rl_synonyms_} +\title{Get species narrative information by taxon name or IUCN id} +\usage{ +rl_synonyms(name = NULL, key = NULL, parse = TRUE, ...) + +rl_synonyms_(name = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get species narrative information by taxon name or IUCN id +} +\examples{ +\dontrun{ +rl_synonyms('Loxodonta africana') +rl_synonyms('Loxodonta africana', parse = FALSE) +rl_synonyms_('Loxodonta africana') +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rl_threats.Rd b/man/rl_threats.Rd new file mode 100644 index 0000000..296075f --- /dev/null +++ b/man/rl_threats.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rl_threats.R +\name{rl_threats} +\alias{rl_threats} +\alias{rl_threats_} +\title{Get species threats by taxon name or IUCN id} +\usage{ +rl_threats(name = NULL, id = NULL, region = NULL, key = NULL, + parse = TRUE, ...) + +rl_threats_(name = NULL, id = NULL, region = NULL, key = NULL, ...) +} +\arguments{ +\item{name}{(character) Binomial taxonomic name} + +\item{id}{(character) IUCN id} + +\item{region}{(character) Binomial taxonomic name} + +\item{key}{A IUCN API token} + +\item{parse}{(logical) Whether to parse to list (\code{FALSE}) or +data.frame (\code{TRUE}). Default: \code{TRUE}} + +\item{...}{Curl options passed to \code{\link[httr]{GET}}} +} +\value{ +A list, with the data in the \code{result} slot, unless using +a function with a trailing underscore, in which case json as character +string is returned. +} +\description{ +Get species threats by taxon name or IUCN id +} +\examples{ +\dontrun{ +rl_threats('Fratercula arctica') +rl_threats('Fratercula arctica', region = 'europe') +rl_threats(id = 12392) +rl_threats(id = 22694927, region = 'europe') +rl_threats_('Fratercula arctica') +} +} +\references{ +API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} +} + diff --git a/man/rredlist-package.Rd b/man/rredlist-package.Rd new file mode 100644 index 0000000..d41aba9 --- /dev/null +++ b/man/rredlist-package.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rredlist-package.R +\docType{package} +\name{rredlist-package} +\alias{rredlist} +\alias{rredlist-package} +\title{rredlist} +\description{ +rredlist +} +\keyword{package} + diff --git a/rredlist.Rproj b/rredlist.Rproj new file mode 100644 index 0000000..75e109e --- /dev/null +++ b/rredlist.Rproj @@ -0,0 +1,20 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: pdfLaTeX + +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageCheckArgs: --as-cran