rredlist/0000755000175100001440000000000013150210527012114 5ustar hornikusersrredlist/tests/0000755000175100001440000000000013021451532013256 5ustar hornikusersrredlist/tests/testthat/0000755000175100001440000000000013051655062015125 5ustar hornikusersrredlist/tests/testthat/test-rl_growth_forms.R0000644000175100001440000000415413051655743021454 0ustar hornikuserscontext("rl_growth_forms functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_growth_forms('Quercus robur') expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_named(aa$result, "name") }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_growth_forms('Quercus robur', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "list") expect_named(aa$result[[1]], "name") }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_growth_forms_('Mucuna bracteata') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("name", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_growth_forms('Mucuna asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_growth_forms(5), "name must be of class character") expect_error(rl_growth_forms(list()), "name must be of class character") expect_error(rl_growth_forms(id = "adsfds"), "id must be of class integer, numeric") expect_error(rl_growth_forms(id = list()), "id must be of class integer, numeric") expect_error(rl_growth_forms("ad", region = 5), "region must be of class character") expect_error(rl_growth_forms("ad", region = list()), "region must be of class character") expect_error(rl_growth_forms(key = 5), "key must be of class character") expect_error(rl_growth_forms(key = matrix()), "key must be of class character") expect_error(rl_growth_forms(parse = 5), "parse must be of class logical") expect_error(rl_growth_forms(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_growth_forms(letters[1:2]), "name must be length 1") expect_error(rl_growth_forms(id = 1:2), "id must be length 1") expect_error(rl_growth_forms(letters[1], region = letters[1:2]), "region must be length 1") }) rredlist/tests/testthat/test-rl_common_names.R0000644000175100001440000000312713035532077021402 0ustar hornikuserscontext("rl_common_names functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_common_names('Loxodonta africana') expect_is(aa, "list") expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_true(any(grepl("elephant", aa$result$taxonname, ignore.case = TRUE))) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_common_names('Loxodonta africana', parse = FALSE) expect_is(aa, "list") expect_is(aa$name, "character") expect_is(aa$result, "list") expect_true(any(grepl("elephant", vapply(aa$result, "[[", "", "taxonname"), ignore.case = TRUE))) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_common_names_('Loxodonta africana') expect_is(aa, "character") expect_is(jsonlite::fromJSON(aa), "list") }) test_that("no results", { skip_on_cran() aa <- rl_common_names('Loxodonta asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_common_names(5), "name must be of class character") expect_error(rl_common_names(list()), "name must be of class character") expect_error(rl_common_names(key = 5), "key must be of class character") expect_error(rl_common_names(key = matrix()), "key must be of class character") expect_error(rl_common_names(parse = 5), "parse must be of class logical") expect_error(rl_common_names(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_common_names(letters[1:2]), "name must be length 1") }) rredlist/tests/testthat/test-rl_history.R0000644000175100001440000000534513035531722020430 0ustar hornikuserscontext("rl_history functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_history('Loxodonta africana') expect_is(aa, "list") expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_true(any(grepl("Vulnerable", aa$result$category, ignore.case = TRUE))) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_history('Loxodonta africana', parse = FALSE) expect_is(aa, "list") expect_is(aa$name, "character") expect_is(aa$result, "list") expect_true(any(grepl("Vulnerable", vapply(aa$result, "[[", "", "category"), ignore.case = TRUE))) }) test_that("high level works - by ID", { skip_on_cran() aa <- rl_history(id = 12392) expect_is(aa, "list") expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_true(any(grepl("Vulnerable", aa$result$category, ignore.case = TRUE))) }) test_that("high level works - region", { skip_on_cran() aa <- rl_history(id = 22823, region = 'europe') bb <- rl_history(id = 22823, region = 'mediterranean') expect_is(aa, "list") expect_named(aa, c('name', 'region_identifier', 'result')) expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_gt(NROW(aa$result), 0) expect_is(bb, "list") expect_named(bb, c('name', 'region_identifier', 'result')) expect_is(bb$name, "character") expect_is(bb$result, "list") expect_equal(length(bb$result), 0) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_history_('Ursus maritimus', region = 'europe') expect_is(aa, "character") expect_is(jsonlite::fromJSON(aa), "list") }) test_that("fails well", { skip_on_cran() expect_error(rl_history(), "is not TRUE") }) test_that("fails well", { skip_on_cran() expect_error(rl_history(5), "name must be of class character") expect_error(rl_history(list()), "name must be of class character") expect_error(rl_history(id = "adsfds"), "id must be of class integer, numeric") expect_error(rl_history(id = list()), "id must be of class integer, numeric") expect_error(rl_history("ab", region = 5), "region must be of class character") expect_error(rl_history("ab", region = list()), "region must be of class character") expect_error(rl_history(key = 5), "key must be of class character") expect_error(rl_history(key = matrix()), "key must be of class character") expect_error(rl_history(parse = 5), "parse must be of class logical") expect_error(rl_history(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_history(letters[1:2]), "name must be length 1") expect_error(rl_history(id = 1:2), "id must be length 1") expect_error(rl_history(letters[1], region = letters[1:2]), "region must be length 1") }) rredlist/tests/testthat/test-rl_countries.R0000644000175100001440000000213413035532034020730 0ustar hornikuserscontext("rl_countries functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_countries() expect_is(aa, "list") expect_type(aa$count, "integer") expect_is(aa$results, "data.frame") expect_true(any(grepl("Egypt", aa$results$country, ignore.case = TRUE))) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_countries(parse = FALSE) expect_is(aa, "list") expect_type(aa$count, "integer") expect_is(aa$results, "list") expect_true(any(grepl("Egypt", vapply(aa$results, "[[", "", "country"), ignore.case = TRUE))) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_countries_() expect_is(aa, "character") expect_is(jsonlite::fromJSON(aa), "list") }) test_that("fails well", { skip_on_cran() expect_error(rl_countries(key = 5), "key must be of class character") expect_error(rl_countries(key = matrix()), "key must be of class character") expect_error(rl_countries(parse = 5), "parse must be of class logical") expect_error(rl_countries(parse = matrix()), "parse must be of class logical") }) rredlist/tests/testthat/test-rl_narrative.R0000644000175100001440000000424613035531626020724 0ustar hornikuserscontext("rl_narrative functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_narrative('Fratercula arctica') expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_named(aa$result[,1:3], c("species_id", "taxonomicnotes", "rationale")) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_narrative('Fratercula arctica', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "list") expect_named(aa$result[[1]][1:3], c("species_id", "taxonomicnotes", "rationale")) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_narrative_('Fratercula arctica') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("name", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_narrative('Loxodonta asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_narrative(5), "name must be of class character") expect_error(rl_narrative(list()), "name must be of class character") expect_error(rl_narrative(id = "adsfds"), "id must be of class integer, numeric") expect_error(rl_narrative(id = list()), "id must be of class integer, numeric") expect_error(rl_narrative("adsfa", region = 5), "region must be of class character") expect_error(rl_narrative("adsfa", region = list()), "region must be of class character") expect_error(rl_narrative(key = 5), "key must be of class character") expect_error(rl_narrative(key = matrix()), "key must be of class character") expect_error(rl_narrative(parse = 5), "parse must be of class logical") expect_error(rl_narrative(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_narrative(letters[1:2]), "name must be length 1") expect_error(rl_narrative(id = 1:2), "id must be length 1") expect_error(rl_narrative(letters[1], region = letters[1:2]), "region must be length 1") }) rredlist/tests/testthat/test-rl_version.R0000644000175100001440000000046213035472734020416 0ustar hornikuserscontext("rl_version functions") test_that("rl_version works", { skip_on_cran() aa <- rl_version() expect_is(aa, "character") expect_match(aa, "[0-9]{4}-[0-9]") }) test_that("rl_version curl options work", { skip_on_cran() expect_error(rl_version(timeout_ms = 1), "Timeout was reached") }) rredlist/tests/testthat/test-rl_citation.R0000644000175100001440000000052713035472624020543 0ustar hornikuserscontext("rl_citation functions") test_that("rl_citation works", { skip_on_cran() aa <- rl_citation() expect_is(aa, "character") expect_match(aa, "IUCN") expect_match(aa, "www.iucnredlist.org") }) test_that("rl_citation curl options work", { skip_on_cran() expect_error(rl_citation(timeout_ms = 1), "Timeout was reached") }) rredlist/tests/testthat/test-rl_threats.R0000644000175100001440000000413113035533700020367 0ustar hornikuserscontext("rl_threats functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_threats('Fratercula arctica') expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_named(aa$result[,1:3], c("code", "title", "timing")) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_threats('Fratercula arctica', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "list") expect_named(aa$result[[1]][1:3], c("code", "title", "timing")) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_threats_('Fratercula arctica') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("name", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_threats('Loxodonta asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_threats(5), "name must be of class character") expect_error(rl_threats(list()), "name must be of class character") expect_error(rl_threats(id = "adsfds"), "id must be of class integer, numeric") expect_error(rl_threats(id = list()), "id must be of class integer, numeric") expect_error(rl_threats("ad", region = 5), "region must be of class character") expect_error(rl_threats("ad", region = list()), "region must be of class character") expect_error(rl_threats(key = 5), "key must be of class character") expect_error(rl_threats(key = matrix()), "key must be of class character") expect_error(rl_threats(parse = 5), "parse must be of class logical") expect_error(rl_threats(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_threats(letters[1:2]), "name must be length 1") expect_error(rl_threats(id = 1:2), "id must be length 1") expect_error(rl_threats(letters[1], region = letters[1:2]), "region must be length 1") }) rredlist/tests/testthat/test-rl_measures.R0000644000175100001440000000411313035531671020546 0ustar hornikuserscontext("rl_measures functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_measures('Fratercula arctica') expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_named(aa$result, c("code", "title")) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_measures('Fratercula arctica', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "list") expect_named(aa$result[[1]], c("code", "title")) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_measures_('Fratercula arctica') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("name", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_measures('Loxodonta asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_measures(5), "name must be of class character") expect_error(rl_measures(list()), "name must be of class character") expect_error(rl_measures(id = "adsfds"), "id must be of class integer, numeric") expect_error(rl_measures(id = list()), "id must be of class integer, numeric") expect_error(rl_measures("ad", region = 5), "region must be of class character") expect_error(rl_measures("ad", region = list()), "region must be of class character") expect_error(rl_measures(key = 5), "key must be of class character") expect_error(rl_measures(key = matrix()), "key must be of class character") expect_error(rl_measures(parse = 5), "parse must be of class logical") expect_error(rl_measures(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_measures(letters[1:2]), "name must be length 1") expect_error(rl_measures(id = 1:2), "id must be length 1") expect_error(rl_measures(letters[1], region = letters[1:2]), "region must be length 1") }) rredlist/tests/testthat/test-rl_sp_category.R0000644000175100001440000000362313035531441021241 0ustar hornikuserscontext("rl_sp_category functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_sp_category('VU') expect_is(aa, "list") expect_named(aa, c("count", "category", "result")) expect_is(aa$count, "integer") expect_is(aa$category, "character") expect_equal(aa$category, "VU") expect_is(aa$result, "data.frame") expect_named(aa$result, c('taxonid', 'scientific_name', 'subspecies', 'rank', 'subpopulation')) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_sp_category('VU', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("count", "category", "result")) expect_is(aa$count, "integer") expect_is(aa$category, "character") expect_equal(aa$category, "VU") expect_is(aa$result, "list") expect_named(aa$result[[1]], c('taxonid', 'scientific_name', 'subspecies', 'rank', 'subpopulation')) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_sp_category_('VU') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("count", "category", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_sp_category('asdfad') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_sp_category(5), "category must be of class character") expect_error(rl_sp_category(list()), "category must be of class character") expect_error(rl_sp_category(key = 5), "key must be of class character") expect_error(rl_sp_category(key = matrix()), "key must be of class character") expect_error(rl_sp_category(parse = 5), "parse must be of class logical") expect_error(rl_sp_category(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_sp_category(letters[1:2]), "category must be length 1") }) rredlist/tests/testthat/test-fail-well.R0000644000175100001440000000230113035516615020077 0ustar hornikuserscontext("package fails well") test_that("fails well on bad key", { skip_on_cran() expect_error(rl_common_names('Loxodonta africana', key = "adfds"), "Token not valid!") expect_error(rl_common_names_('Loxodonta africana', key = "adfds"), "Token not valid") }) test_that("fails well when correct parameters not given", { skip_on_cran() expect_error(rl_search(), "is not TRUE") expect_error(rl_search_(), "is not TRUE") }) test_that("fails well when an invalid region passed", { skip_on_cran() # results in an `error` slot, which we catch expect_error(rl_habitats(id = 22694927, region = 34234), "region must be of class character") expect_error(rl_habitats_(id = 22694927, region = '34234'), "Region not found.") expect_error(rl_search(id = 22694927, region = 2727343), "region must be of class character") expect_error(rl_search_(id = 22694927, region = '3wer'), "Region not found.") expect_error(rl_measures(id = 22694927, region = 12345), "region must be of class character") expect_error(rl_measures_(id = 22694927, region = '3wer'), "Region not found.") }) rredlist/tests/testthat/test-rl_habitat.R0000644000175100001440000000422713035531765020350 0ustar hornikuserscontext("rl_habitats functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_habitats('Fratercula arctica') expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_true(any(grepl("breeding", aa$result$season, ignore.case = TRUE))) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_habitats('Fratercula arctica', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "list") expect_true(any(grepl("breeding", vapply(aa$result, "[[", "", "season"), ignore.case = TRUE))) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_habitats_('Fratercula arctica') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("name", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_habitats('Loxodonta asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_habitats(5), "name must be of class character") expect_error(rl_habitats(list()), "name must be of class character") expect_error(rl_habitats(id = "adsfds"), "id must be of class integer, numeric") expect_error(rl_habitats(id = list()), "id must be of class integer, numeric") expect_error(rl_habitats("ab", region = 5), "region must be of class character") expect_error(rl_habitats("ab", region = list()), "region must be of class character") expect_error(rl_habitats(key = 5), "key must be of class character") expect_error(rl_habitats(key = matrix()), "key must be of class character") expect_error(rl_habitats(parse = 5), "parse must be of class logical") expect_error(rl_habitats(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_habitats(letters[1:2]), "name must be length 1") expect_error(rl_habitats(id = 1:2), "id must be length 1") expect_error(rl_habitats(letters[1], region = letters[1:2]), "region must be length 1") }) rredlist/tests/testthat/test-rl_synonyms.R0000644000175100001440000000351713035531255020626 0ustar hornikuserscontext("rl_synonyms functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_synonyms('Loxodonta africana') expect_is(aa, "list") expect_named(aa, c("name", "count", "result")) expect_is(aa$name, "character") expect_is(aa$count, "integer") expect_is(aa$result, "data.frame") expect_named(aa$result, c('accepted_id', 'accepted_name', 'authority', 'synonym', 'syn_authority')) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_synonyms('Loxodonta africana', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("name", "count", "result")) expect_is(aa$name, "character") expect_is(aa$count, "integer") expect_is(aa$result, "list") expect_named(aa$result[[1]], c('accepted_id', 'accepted_name', 'authority', 'synonym', 'syn_authority')) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_synonyms_('Loxodonta africana') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("name", "count", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_synonyms('Loxodonta asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_synonyms(5), "name must be of class character") expect_error(rl_synonyms(list()), "name must be of class character") expect_error(rl_synonyms(key = 5), "key must be of class character") expect_error(rl_synonyms(key = matrix()), "key must be of class character") expect_error(rl_synonyms(parse = 5), "parse must be of class logical") expect_error(rl_synonyms(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_synonyms(letters[1:2]), "name must be length 1") }) rredlist/tests/testthat/test-rl_search.R0000644000175100001440000000421313035531563020170 0ustar hornikuserscontext("rl_search functions") test_that("high level works - parsing", { skip_on_cran() aa <- rl_search('Fratercula arctica') expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "data.frame") expect_true(any(grepl("arctica", aa$result$scientific_name, ignore.case = TRUE))) }) test_that("high level works - not parsing", { skip_on_cran() aa <- rl_search('Fratercula arctica', parse = FALSE) expect_is(aa, "list") expect_named(aa, c("name", "result")) expect_is(aa$name, "character") expect_is(aa$result, "list") expect_true(any(grepl("arctica", vapply(aa$result, "[[", "", "scientific_name"), ignore.case = TRUE))) }) test_that("low level works", { skip_on_cran() library("jsonlite") aa <- rl_search_('Fratercula arctica') aajson <- jsonlite::fromJSON(aa) expect_is(aa, "character") expect_is(aajson, "list") expect_named(aajson, c("name", "result")) }) test_that("no results", { skip_on_cran() aa <- rl_search('Loxodonta asdfadf') expect_is(aa, "list") expect_is(aa$result, "list") expect_equal(length(aa$result), 0) }) test_that("fails well", { skip_on_cran() expect_error(rl_search(5), "name must be of class character") expect_error(rl_search(list()), "name must be of class character") expect_error(rl_search(id = "adsfds"), "id must be of class integer, numeric") expect_error(rl_search(id = list()), "id must be of class integer, numeric") expect_error(rl_search("adfadf", region = 5), "region must be of class character") expect_error(rl_search("adfadf", region = list()), "region must be of class character") expect_error(rl_search(key = 5), "key must be of class character") expect_error(rl_search(key = matrix()), "key must be of class character") expect_error(rl_search(parse = 5), "parse must be of class logical") expect_error(rl_search(parse = matrix()), "parse must be of class logical") # lengths expect_error(rl_search(letters[1:2]), "name must be length 1") expect_error(rl_search(id = 1:2), "id must be length 1") expect_error(rl_search(letters[1], region = letters[1:2]), "region must be length 1") }) rredlist/tests/test-all.R0000644000175100001440000000005113021451532015122 0ustar hornikuserslibrary(testthat) test_check("rredlist") rredlist/NAMESPACE0000644000175100001440000000150013051655435013342 0ustar hornikusers# Generated by roxygen2: do not edit by hand export(rl_citation) export(rl_common_names) export(rl_common_names_) export(rl_countries) export(rl_countries_) export(rl_growth_forms) export(rl_growth_forms_) export(rl_habitats) export(rl_habitats_) export(rl_history) export(rl_history_) export(rl_measures) export(rl_measures_) export(rl_narrative) export(rl_narrative_) export(rl_occ_country) export(rl_occ_country_) 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_) export(rl_version) importFrom(jsonlite,fromJSON) rredlist/NEWS.md0000644000175100001440000000465213150123235013220 0ustar hornikusersrredlist 0.4.0 ============== ### NEW FEATURES * Gains new functions `rl_growth_forms()` and `rl_growth_forms_()`. added tests for them as well (#20) thanks @stevenpbachman ### MINOR IMPROVEMENTS * Now using markdown documentation (#22) * Fixed many man files which for `region` parameter described requiring a taxonomic name - fixed to describe accurately. Also improved docs in general (#21) * Added the options for `category` parameter in `rl_sp_category()` function * Added in docs for `rl_sp_country` how to get acceptable country codes to pass to `country` parameter * Added to package level manual file `?rredlist-package` a note from the IUCN Redlist API documentation about that they suggest using taxonomic names instead of IDs because IDs can change through time rredlist 0.3.0 ============== ### NEW FEATURES * New functions `rl_occ_country` and `rl_occ_country_` for getting country occurrences by species name or ID (#13) * Replaced `httr` with `crul`. Please note this only affects use of curl options. See `crul` docs for how to use curl options (#14) ### MINOR IMPROVEMENTS * User agent string like `r-curl/2.3 crul/0.2.0 rOpenSci(rredlist/0.3.0)` sent in all requests now to help IUCN API maintainers know how often requests come from R and this package (#19) * Taxon names are now given back in `rl_threats` - we didn't do anything in the package - the API now gives the names back and adds them in a column (#10) * Type checking all parameter inputs now both in terms of class and length - with helpful error messages on fail (#17) * Simplify package codebase by having single internal function for a suite of half a dozen or so functions that have similar pattern (#18) * Removed `key` parameter from `rl_version()` and `rl_citation()` as API key not required for those methods * More thorough test suite rredlist 0.2.0 ============== ### NEW FEATURES * New methods added to get historical assessments: `rl_history()` and `rl_history_()` (#8) ### MINOR IMPROVEMENTS * Fixed description of what `rl_common_names` does. In addition, clarified descriptino of what other functions do as well, whenever it was unclear (#12) ### BUG FIXES * Some API tokens were being blocked, fixed now (#7) * On some operating systems (at least some versions of Windows), queries that included taxonomic names weren't being processed correctly. It is fixed now (#11) rredlist 0.1.0 ============== ### NEW FEATURES * Released to CRAN. rredlist/R/0000755000175100001440000000000013051654700012322 5ustar hornikusersrredlist/R/rl_search.R0000644000175100001440000000161213150117167014410 0ustar hornikusers#' Search by taxon name, IUCN id, and region #' #' @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, ...) { assert_is(parse, 'logical') rl_parse(rl_search_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_search rl_search_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("species", "species/id", name, id, region), key, ...) } rredlist/R/rl_growth_forms.R0000644000175100001440000000213213150117213015651 0ustar hornikusers#' Get plant species growth forms by taxon name, IUCN id, and region #' #' @export #' @template commonargs #' @template all #' @template info #' @examples \dontrun{ #' rl_growth_forms('Quercus robur') #' rl_growth_forms('Quercus robur', region = 'europe') #' rl_growth_forms(id = 63532) #' rl_growth_forms(id = 63532, region = 'europe') #' #' rl_growth_forms('Mucuna bracteata') #' rl_growth_forms('Abarema villifera') #' rl_growth_forms('Adansonia perrieri') #' rl_growth_forms('Adenostemma harlingii') #' #' rl_growth_forms_('Quercus robur') #' rl_growth_forms_(id = 63532, region = 'europe') #' } rl_growth_forms <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_growth_forms_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_growth_forms rl_growth_forms_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("growth_forms/species/name", "growth_forms/species/id", name, id, region), key, ...) } rredlist/R/rl_synonyms.R0000644000175100001440000000126713035530611015043 0ustar hornikusers#' Get species synonym information by taxonomic name #' #' @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, ...) { assert_is(parse, 'logical') rl_parse(rl_synonyms_(name, key, ...), parse) } #' @export #' @rdname rl_synonyms rl_synonyms_ <- function(name = NULL, key = NULL, ...) { assert_is(key, 'character') assert_is(name, 'character') assert_n(name, 1) rr_GET(file.path("species/synonym", space(name)), key, ...) } rredlist/R/rl_threats.R0000644000175100001440000000162213150117164014613 0ustar hornikusers#' Get species threats by taxon name, IUCN id, and region #' #' @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(name = 'Abies numidica') #' rl_threats_('Fratercula arctica') #' #' rl_threats(id = 62290750) #' } rl_threats <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_threats_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_threats rl_threats_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("threats/species/name", "threats/species/id", name, id, region), key, ...) } rredlist/R/rl_version.R0000644000175100001440000000042613150117435014630 0ustar hornikusers#' Get the Red List API version #' #' @export #' @param ... Curl options passed to [crul::HttpClient()] #' @return API version as character string #' @examples \dontrun{ #' rl_version() #' } rl_version <- function(...) { rl_parse(rr_GET("version", NULL, ...), TRUE)$version } rredlist/R/rl_sp_count.R0000644000175100001440000000067013035530570014777 0ustar hornikusers#' Get total species count of taxa in the Red List #' #' @export #' @template all #' @template info #' @examples \dontrun{ #' rl_sp_count() #' rl_sp_count_() #' } rl_sp_count <- function(key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_sp_count_(key, ...), parse) } #' @export #' @rdname rl_sp_count rl_sp_count_ <- function(key = NULL, ...) { assert_is(key, 'character') rr_GET("speciescount", key, ...) } rredlist/R/rl_occ_country.R0000644000175100001440000000174213150117171015471 0ustar hornikusers#' Get country occurrence by species name or ID #' #' @export #' @template commonargs #' @template all #' @template info #' @examples \dontrun{ #' rl_occ_country('Loxodonta africana') #' rl_occ_country('Fratercula arctica', region = 'europe') #' rl_occ_country(id = 12392) #' rl_occ_country(id = 22694927, region = 'europe') #' #' rl_occ_country('Fratercula arctica', parse = FALSE) #' rl_occ_country_('Fratercula arctica') #' rl_occ_country_('Fratercula arctica', region = 'europe') #' } rl_occ_country <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_occ_country_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_search rl_occ_country_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("species/countries/name", "species/countries/id", name, id, region), key, ...) } rredlist/R/rl_countries.R0000644000175100001440000000063413035530252015155 0ustar hornikusers#' Get countries #' #' @export #' @template all #' @template info #' @examples \dontrun{ #' rl_countries() #' rl_countries_() #' } rl_countries <- function(key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_countries_(key, ...), parse) } #' @export #' @rdname rl_countries rl_countries_ <- function(key = NULL, ...) { assert_is(key, 'character') rr_GET("country/list", key, ...) } rredlist/R/rl_sp_citation.R0000644000175100001440000000166413150117165015464 0ustar hornikusers#' Get citations by taxon name, IUCN id, and region #' #' @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, ...) { assert_is(parse, 'logical') rl_parse(rl_sp_citation_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_sp_citation rl_sp_citation_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("species/citation", "species/citation/id", name, id, region), key, ...) } rredlist/R/rredlist-package.R0000644000175100001440000000437113150117401015663 0ustar hornikusers#' rredlist - IUCN Red List Client #' #' @section Taxonomic Names vs. IUCN IDs: #' From the documentation (quoting): "It is advisable wherever possible to use #' the taxon name (species name) to make your API calls, rather than using IDs. #' IDs are not immovable are expected to be used mainly by organisations #' that work closely with the IUCN Red List." #' #' @section Authentication: #' IUCN requires you to get your own API key, an alphanumeric string that you #' need to send in every request. Get it at #' #' Keep this key private. You can pass the key in to each function via the #' `key` parameter, but it's better to store the key either as a #' environment variable (`IUCN_REDLIST_KEY`) or an R option #' (`iucn_redlist_key`) - we suggest using the former option. #' #' @section High vs. Low level package APIs: #' **High level API** #' High level functions do the HTTP request and parse data to a data.frame for #' ease of downstream use. The high level functions have no underscore on #' the end of the function name, e.g., [rl_search()] #' #' **Low level API** #' The parsing to data.frame in the high level API does take extra time. #' The low level API only does the HTTP request, and gives back JSON without #' doing any more parsing. The low level functions DO have an underscore on #' the end of the function name, e.g., [rl_search_()] #' #' @section No Spatial: #' This package does not include support for the spatial API, described at #' #' #' @section Citing the Red List API: #' The citation is #' `IUCN 2015. IUCN Red List of Threatened Species. Version 2015-4 #' ` #' You can get this programatically via [rl_citation()] #' #' @section Rate limiting: #' From the IUCN folks: Too many frequent calls, or too many calls per day #' might get your access blocked temporarily. If you're a heavy API user, the #' Red List Unit asked that you contact them, as there might be better options. #' They suggest a 2-second delay between your calls if you plan to make a #' lot of calls. #' #' @importFrom jsonlite fromJSON #' @name rredlist-package #' @aliases rredlist #' @docType package #' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} #' @keywords package NULL rredlist/R/rl_citation.R0000644000175100001440000000054413150117477014764 0ustar hornikusers#' Get the citation Red List API version #' #' @export #' @param ... Curl options passed to [crul::HttpClient()] #' @return API citation as character string #' @examples \dontrun{ #' rl_citation() #' } rl_citation <- function(...) { sprintf('IUCN 2015. IUCN Red List of Threatened Species. Version %s ', rl_version(...)) } rredlist/R/rl_regions.R0000644000175100001440000000065213035530516014613 0ustar hornikusers#' Get regions #' #' @export #' @template all #' @template info #' @examples \dontrun{ #' rl_regions() #' rl_regions(parse = FALSE) #' rl_regions_() #' } rl_regions <- function(key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_regions_(key, ...), parse) } #' @export #' @rdname rl_regions rl_regions_ <- function(key = NULL, ...) { assert_is(key, 'character') rr_GET("region/list", key, ...) } rredlist/R/rl_sp_country.R0000644000175100001440000000160013150117707015345 0ustar hornikusers#' Get species by country #' #' @export #' @param country (character) A two-letter country code. See `isocode` column #' in result of [rl_countries()] request for country codes. #' @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 #' res <- rl_sp_country('NZ', verbose = TRUE) #' } rl_sp_country <- function(country, key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_sp_country_(country, key, ...), parse) } #' @export #' @rdname rl_sp_country rl_sp_country_ <- function(country, key = NULL, ...) { assert_is(key, 'character') assert_is(country, 'character') assert_n(country, 1) rr_GET(file.path("country/getspecies", country), key, ...) } rredlist/R/rl_habitats.R0000644000175100001440000000156413150117210014735 0ustar hornikusers#' Get species habitats by taxon name, IUCN id, and region #' #' @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, ...) { assert_is(parse, 'logical') rl_parse(rl_habitats_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_habitats rl_habitats_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("habitats/species/name", "habitats/species/id", name, id, region), key, ...) } rredlist/R/rl_narrative.R0000644000175100001440000000165313150117172015137 0ustar hornikusers#' Get species narrative information by taxon name, IUCN id, and region #' #' @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, ...) { assert_is(parse, 'logical') rl_parse(rl_narrative_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_narrative rl_narrative_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("species/narrative", "species/narrative/id", name, id, region), key, ...) } rredlist/R/rl_history.R0000644000175100001440000000155313150117235014644 0ustar hornikusers#' Get historical assessments by taxon name, IUCN id, and region #' #' @export #' @template commonargs #' @template all #' @template info #' @examples \dontrun{ #' rl_history('Loxodonta africana') #' rl_history('Ursus maritimus', region = 'europe') #' rl_history(id = 12392) #' rl_history(id = 22823, region = 'europe') #' #' rl_history_('Loxodonta africana') #' rl_history_(id = 12392) #' } rl_history <- function(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_history_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_habitats rl_history_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("species/history/name", "species/history/id", name, id, region), key, ...) } rredlist/R/rl_common_names.R0000644000175100001440000000123213035530411015605 0ustar hornikusers#' Get common names for a given taxonomic name #' #' @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, ...) { assert_is(parse, 'logical') rl_parse(rl_common_names_(name, key, ...), parse) } #' @export #' @rdname rl_common_names rl_common_names_ <- function(name = NULL, key = NULL, ...) { assert_is(key, 'character') assert_is(name, 'character') assert_n(name, 1) rr_GET(file.path("species/common_names", space(name)), key, ...) } rredlist/R/rl_measures.R0000644000175100001440000000163313150117177014773 0ustar hornikusers#' Get species conservation measures by taxon name, IUCN id, and region #' #' @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, ...) { assert_is(parse, 'logical') rl_parse(rl_measures_(name, id, region, key, ...), parse) } #' @export #' @rdname rl_measures rl_measures_ <- function(name = NULL, id = NULL, region = NULL, key = NULL, ...) { assert_is(key, 'character') rr_GET(nir("measures/species/name", "measures/species/id", name, id, region), key, ...) } rredlist/R/rl_sp_category.R0000644000175100001440000000144513150120000015442 0ustar hornikusers#' Get species by category #' #' @export #' @param category (character) A two-letter category code. One of #' "DD", "LC", "NT", "VU", "EN", "CR", "EW", "EX", "LRlc", "LRnt", "LRcd" #' @template all #' @examples \dontrun{ #' rl_sp_category('VU') #' rl_sp_category('LRlc') #' 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, ...) { assert_is(parse, 'logical') rl_parse(rl_sp_category_(category, key, ...), parse) } #' @export #' @rdname rl_sp_category rl_sp_category_ <- function(category, key = NULL, parse = TRUE, ...) { assert_is(key, 'character') assert_is(category, 'character') assert_n(category, 1) rr_GET(file.path("species/category", category), key, ...) } rredlist/R/rl_sp.R0000644000175100001440000000076513035530541013572 0ustar hornikusers#' Get species #' #' @export #' @param page (integer/numeric) Page to get. Default: 1 #' @template all #' @examples \dontrun{ #' rl_sp(page = 3) #' } rl_sp <- function(page, key = NULL, parse = TRUE, ...) { assert_is(parse, 'logical') rl_parse(rl_sp_(page, key, ...), parse) } #' @export #' @rdname rl_sp rl_sp_ <- function(page, key = NULL, ...) { assert_is(key, 'character') assert_is(page, c('integer', 'numeric')) assert_n(page, 1) rr_GET(file.path("species/page", page), key, ...) } rredlist/R/zzz.R0000644000175100001440000000427413035537226013316 0ustar hornikusersct <- function(l) Filter(Negate(is.null), l) rredlist_ua <- function() { versions <- c( paste0("r-curl/", utils::packageVersion("curl")), paste0("crul/", utils::packageVersion("crul")), sprintf("rOpenSci(rredlist/%s)", utils::packageVersion("rredlist")) ) paste0(versions, collapse = " ") } rr_GET <- function(path, key, ...){ cli <- crul::HttpClient$new( url = file.path(rr_base(), path), opts = list(useragent = rredlist_ua()) ) temp <- cli$get(query = list(token = check_key(key)), ...) temp$raise_for_status() x <- temp$parse("UTF-8") err_catcher(x) return(x) } err_catcher <- function(x) { xx <- jsonlite::fromJSON(x) if (any(vapply(c("message", "error"), function(z) z %in% names(xx), logical(1)))) { stop(xx[[1]], call. = FALSE) } } 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 Red List data", call. = FALSE)) } else { tmp } } rr_base <- function() "http://apiv3.iucnredlist.org/api/v3" space <- function(x) gsub("\\s", "%20", x) assert_is <- function(x, y) { if (!is.null(x)) { if (!class(x) %in% y) { stop(deparse(substitute(x)), " must be of class ", paste0(y, collapse = ", "), call. = FALSE) } } } assert_n <- function(x, n) { if (!is.null(x)) { if (!length(x) == n) { stop(deparse(substitute(x)), " must be length ", n, call. = FALSE) } } } nir <- function(path_name, path_id, name = NULL, id = NULL, region = NULL) { # only one of name OR id stopifnot(xor(!is.null(name), !is.null(id))) # check types assert_is(name, 'character') assert_is(id, c('integer', 'numeric')) assert_is(region, 'character') # check lengths - only length 1 allowed for all assert_n(name, 1) assert_n(id, 1) assert_n(region, 1) # construct path path <- if (!is.null(name)) { file.path(path_name, space(name)) } else { file.path(path_id, id) } if (!is.null(region)) { path <- file.path(path, "region", space(region)) } return(path) } rredlist/README.md0000644000175100001440000001473613150122037013404 0ustar hornikusersrredlist ======== [![Build Status](https://travis-ci.org/ropensci/rredlist.svg?branch=master)](https://travis-ci.org/ropensci/rredlist) [![codecov.io](https://codecov.io/github/ropensci/rredlist/coverage.svg?branch=master)](https://codecov.io/github/ropensci/rredlist?branch=master) [![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/rredlist)](https://github.com/metacran/cranlogs.app) [![cran version](http://www.r-pkg.org/badges/version/rredlist)](https://cran.r-project.org/package=rredlist) [IUCN Red List docs][docs] ## Authentication IUCN requires you to get your own API key, an alphanumeric string that you need to send in every request. Get it at . Keep this key private. You can pass the key in to each function via the `key` parameter, but it's better to store the key either as a environment variable (`IUCN_REDLIST_KEY`) or an R option (`iucn_redlist_key`) - we suggest using the former option. ## High vs. Low level package APIs __High level API__ High level functions do the HTTP request and parse data to a data.frame for ease of downstream use. The high level functions have no underscore on the end of the function name, e.g., `rl_search` __Low level API__ The parsing to data.frame in the high level API does take extra time. The low level API only does the HTTP request, and gives back JSON without doing any more parsing. The low level functions DO have an underscore on the end of the function name, e.g., `rl_search_` ## No Spatial This package does not include support for the spatial API, described at [http://apiv3.iucnredlist.org/spatial][spatial]. ## Citing IUCN API use the function `rl_citation()` ```r rl_citation() #> [1] "IUCN 2015. IUCN Red List of Threatened Species. Version 2017-1 " ``` ## Install CRAN ```r install.packages("rredlist") ``` Development version ```r devtools::install_github("ropensci/rredlist") ``` ```r library("rredlist") ``` ## High level API High level functions do the HTTP request and parse to data to a data.frame for ease of downstream use. ```r rl_search('Fratercula arctica') #> $name #> [1] "Fratercula arctica" #> #> $result #> taxonid scientific_name kingdom phylum class order #> 1 22694927 Fratercula arctica ANIMALIA CHORDATA AVES CHARADRIIFORMES #> family genus main_common_name authority published_year #> 1 ALCIDAE Fratercula Atlantic Puffin (Linnaeus, 1758) 2017 #> category criteria marine_system freshwater_system terrestrial_system #> 1 VU A4abcde TRUE FALSE TRUE #> assessor reviewer aoo_km2 eoo_km2 #> 1 BirdLife International Butchart, S. & Symes, A. NA 20800000 #> elevation_upper elevation_lower depth_upper depth_lower errata_flag #> 1 NA NA NA NA FALSE #> errata_reason #> 1 NA ``` Likely a bit faster is to parse to a list only, and not take the extra data.frame parsing time ```r rl_search('Fratercula arctica', parse = FALSE) #> $name #> [1] "Fratercula arctica" #> #> $result #> $result[[1]] #> $result[[1]]$taxonid #> [1] 22694927 #> #> $result[[1]]$scientific_name #> [1] "Fratercula arctica" ... ``` ## Low level API The parsing to data.frame in the high level API does take extra time. The low level API only does the HTTP request, and gives back JSON without doing any more parsing ```r rl_search_('Fratercula arctica') #> [1] "{\"name\":\"Fratercula arctica\",\"result\":[{\"taxonid\":22694927,\"scientific_name\":\"Fratercula arctica\",\"kingdom\":\"ANIMALIA\",\"phylum\":\"CHORDATA\",\"class\":\"AVES\",\"order\":\"CHARADRIIFORMES\",\"family\":\"ALCIDAE\",\"genus\":\"Fratercula\",\"main_common_name\":\"Atlantic Puffin\",\"authority\":\"(Linnaeus, 1758)\",\"published_year\":2017,\"category\":\"VU\",\"criteria\":\"A4abcde\",\"marine_system\":true,\"freshwater_system\":false,\"terrestrial_system\":true,\"assessor\":\"BirdLife International\",\"reviewer\":\"Butchart, S. & Symes, A.\",\"aoo_km2\":null,\"eoo_km2\":\"20800000\",\"elevation_upper\":null,\"elevation_lower\":null,\"depth_upper\":null,\"depth_lower\":null,\"errata_flag\":false,\"errata_reason\":null}]}" ``` To consume this JSON, you can use `jsonlite` ```r library("jsonlite") jsonlite::fromJSON(rl_search_('Fratercula arctica')) #> $name #> [1] "Fratercula arctica" #> #> $result #> taxonid scientific_name kingdom phylum class order #> 1 22694927 Fratercula arctica ANIMALIA CHORDATA AVES CHARADRIIFORMES #> family genus main_common_name authority published_year #> 1 ALCIDAE Fratercula Atlantic Puffin (Linnaeus, 1758) 2017 #> category criteria marine_system freshwater_system terrestrial_system #> 1 VU A4abcde TRUE FALSE TRUE #> assessor reviewer aoo_km2 eoo_km2 #> 1 BirdLife International Butchart, S. & Symes, A. NA 20800000 #> elevation_upper elevation_lower depth_upper depth_lower errata_flag #> 1 NA NA NA NA FALSE #> errata_reason #> 1 NA ``` Or other tools, e.g., `jq` via the `jqr` R client ```r # devtools::install_github("ropensci/jqr") library("jqr") rl_search_('Fratercula arctica') %>% dot() #> { #> "name": "Fratercula arctica", #> "result": [ #> { #> "taxonid": 22694927, #> "scientific_name": "Fratercula arctica", #> "kingdom": "ANIMALIA", #> "phylum": "CHORDATA", #> "class": "AVES", #> "order": "CHARADRIIFORMES", #> "family": "ALCIDAE", #> "genus": "Fratercula", #> "main_common_name": "Atlantic Puffin", #> "authority": "(Linnaeus, 1758)", #> "published_year": 2017, #> "category": "VU", #> "criteria": "A4abcde", #> "marine_system": true, #> "freshwater_system": false, #> "terrestrial_system": true, ... ``` ## Meta * Please [report any issues or bugs](https://github.com/ropensci/rredlist/issues). * License: MIT * Get citation information for `rredlist` in R doing `citation(package = 'rredlist')` * 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. [docs]: http://apiv3.iucnredlist.org/api/v3/docs [token]: http://apiv3.iucnredlist.org/api/v3/token [spatial]: http://apiv3.iucnredlist.org/spatial rredlist/MD50000644000175100001440000000643413150210527012433 0ustar hornikuserscd0e381706ec9f20be51ca9e6c80180d *DESCRIPTION c5af52351472a750055a760a8924ce71 *LICENSE 0a4f03e553ba60b4a9fa8f38dd25cb51 *NAMESPACE cbf7e6c933a1463f9362f01bbb817022 *NEWS.md 2fd417520f5e264cc5ce6054853d1ba9 *R/rl_citation.R 4d03043dbdfb18f7df49d7b66fb012c2 *R/rl_common_names.R 3e9ee7bbf9c366ef2eba84e3f43f490e *R/rl_countries.R b04ebb961f7af536ddff27d2df811b16 *R/rl_growth_forms.R 385cccf373842340f4a06c221f8f6d9e *R/rl_habitats.R bca4e44fdaeb609d55c9344090bc0f79 *R/rl_history.R 78329f449a6d8ce5df2650dbaac603fc *R/rl_measures.R f03a75e3c552984146142c51294de1f1 *R/rl_narrative.R 04df21e1d25bfeae38e15d9a490d66c0 *R/rl_occ_country.R c92f5de0c1e924576b0d5e9dc5aadf1f *R/rl_regions.R 5204716f15da7732fd8ee2081ab561f7 *R/rl_search.R f0f3d026aef0af0acc8fc7e250ca1919 *R/rl_sp.R 2863324b703907eccf2c2a2c31e76d65 *R/rl_sp_category.R 5aeefc7b42f3f3696af5a0844aace09a *R/rl_sp_citation.R 8931335e5885da2336a9dd7d29af6a05 *R/rl_sp_count.R 2bd94d22712421ed756a157f8240c4aa *R/rl_sp_country.R 9e5f3741f4acb5037d5244e5b0a1993c *R/rl_synonyms.R 4bee8205e89ba38fd20b051a7f88bbd7 *R/rl_threats.R b5597a5e79d52bb331bfb4d82ca4c7c0 *R/rl_version.R 02f1015541815ff4fd0c628cb0a55956 *R/rredlist-package.R a0f098fb4d50eb2c8cf03456ad788ea8 *R/zzz.R a7f96e3a05f6fa5cca5248aba3c6d14a *README.md e53c7dfcb5e697dde659b754e32bda77 *man/rl_citation.Rd c85bde97557aa9d7ed77d5bf567d8402 *man/rl_common_names.Rd 70de0810e3fa3e519838677324e28b91 *man/rl_countries.Rd 34f2d53e73e29a0ddd164e6c0fbc0ebf *man/rl_growth_forms.Rd b8a0d59a6a30a39e84a46351a091383d *man/rl_habitats.Rd a86c04dc54efd9304a5c1567bb9610f7 *man/rl_history.Rd f7f5b16328855b3518f1e06b2d9bc0f4 *man/rl_measures.Rd 5092fa6ab64f20aaec731dce011c491e *man/rl_narrative.Rd 77a30ba259ea70bc44a5cdf3644aba3d *man/rl_occ_country.Rd 5e8660098fb2ec2e4a075b01661706a4 *man/rl_regions.Rd acbb643aec65ca3eafe14039bdc9e2b4 *man/rl_search.Rd 1296a34e51148683cced07aeb64c7187 *man/rl_sp.Rd 5213d1a6fc5d647432a3a01c25429886 *man/rl_sp_category.Rd cbddeb716814c579117ecde8d2615b70 *man/rl_sp_citation.Rd b67392065d06218137cccab98f308532 *man/rl_sp_count.Rd cdf05635471b14bb05e286eb8290560b *man/rl_sp_country.Rd c9c5f10235e29899629dc1847eee6c23 *man/rl_synonyms.Rd 23b536ca1234ad7eba2e66b66dddb8ec *man/rl_threats.Rd a318b5d467d59601faef1be0b5ad2ed6 *man/rl_version.Rd 5938183b1f9aa95f3e125f6d35552c2a *man/rredlist-package.Rd d5da941c797771d510f5e8d756e73c76 *tests/test-all.R 4deb56bf7c6d214fd61a249f690bc6bd *tests/testthat/test-fail-well.R 74f99661ed270bc8be62cb31640d3233 *tests/testthat/test-rl_citation.R 073723ef23fd7b9da35d5debc99c47bf *tests/testthat/test-rl_common_names.R 2f5902b110cb8d7bad1e5ac8ade393e1 *tests/testthat/test-rl_countries.R fce63a71f981e8988d041bc4448e4e0a *tests/testthat/test-rl_growth_forms.R e725c2925af46e5957b209983fae6c13 *tests/testthat/test-rl_habitat.R e0f8497d8988f0ef158cd7ab03c659f9 *tests/testthat/test-rl_history.R 40233433d18aa2e53b3ebeb58e50d08c *tests/testthat/test-rl_measures.R 82c49d673b55d8911f25da7b633e0c9b *tests/testthat/test-rl_narrative.R 4a0a83aad1b4469fcd759c2c2b7d1789 *tests/testthat/test-rl_search.R 8b5229bd070fe858d50e977fc169db18 *tests/testthat/test-rl_sp_category.R 08a3a9058c003424f438c0e748a10840 *tests/testthat/test-rl_synonyms.R ebff0bbc04c482f36d03412954605e16 *tests/testthat/test-rl_threats.R 7ac666ffbdd356dfee2e3c3d1b72b34d *tests/testthat/test-rl_version.R rredlist/DESCRIPTION0000644000175100001440000000154613150210527013630 0ustar hornikusersPackage: rredlist Type: Package Title: 'IUCN' Red List Client Description: 'IUCN' Red List () client. The 'IUCN' Red List is a global list of threatened and endangered species. Functions cover all of the Red List 'API' routes. An 'API' key is required. Version: 0.4.0 Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"), email = "myrmecocystus@gmail.com")) License: MIT + file LICENSE URL: https://github.com/ropensci/rredlist BugReports: https://github.com/ropensci/rredlist/issues Imports: crul (>= 0.3.8), jsonlite (>= 1.1) Suggests: roxygen2 (>= 6.0.1), testthat RoxygenNote: 6.0.1 NeedsCompilation: no Packaged: 2017-08-25 22:51:08 UTC; sacmac Author: Scott Chamberlain [aut, cre] Maintainer: Scott Chamberlain Repository: CRAN Date/Publication: 2017-08-26 06:12:39 UTC rredlist/man/0000755000175100001440000000000013051655435012702 5ustar hornikusersrredlist/man/rl_sp_count.Rd0000644000175100001440000000165413150120021015500 0ustar hornikusers% 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{Get total species count of taxa in the Red List} \usage{ rl_sp_count(key = NULL, parse = TRUE, ...) rl_sp_count_(key = NULL, ...) } \arguments{ \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 total species count of taxa in the Red List } \examples{ \dontrun{ rl_sp_count() rl_sp_count_() } } \references{ API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} } rredlist/man/rl_history.Rd0000644000175100001440000000253413150120021015345 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rl_history.R \name{rl_history} \alias{rl_history} \title{Get historical assessments by taxon name, IUCN id, and region} \usage{ rl_history(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) } \arguments{ \item{name}{(character) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 historical assessments by taxon name, IUCN id, and region } \examples{ \dontrun{ rl_history('Loxodonta africana') rl_history('Ursus maritimus', region = 'europe') rl_history(id = 12392) rl_history(id = 22823, region = 'europe') rl_history_('Loxodonta africana') rl_history_(id = 12392) } } \references{ API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} } rredlist/man/rl_sp_citation.Rd0000644000175100001440000000276513150120021016166 0ustar hornikusers% 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 by taxon name, IUCN id, and region} \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) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 by taxon name, IUCN id, and region } \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} } rredlist/man/rl_search.Rd0000644000175100001440000000311613150120021015106 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rl_occ_country.R, R/rl_search.R \name{rl_occ_country_} \alias{rl_occ_country_} \alias{rl_search} \alias{rl_search_} \title{Search by taxon name, IUCN id, and region} \usage{ rl_occ_country_(name = NULL, id = NULL, region = NULL, key = NULL, ...) 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) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a token} \item{...}{Curl options passed to \code{\link[crul]{HttpClient}}} \item{parse}{(logical) Whether to parse to list (\code{FALSE}) or data.frame (\code{TRUE}). Default: \code{TRUE}} } \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, IUCN id, and region } \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} } rredlist/man/rl_growth_forms.Rd0000644000175100001440000000323113150120021016357 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rl_growth_forms.R \name{rl_growth_forms} \alias{rl_growth_forms} \alias{rl_growth_forms_} \title{Get plant species growth forms by taxon name, IUCN id, and region} \usage{ rl_growth_forms(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) rl_growth_forms_(name = NULL, id = NULL, region = NULL, key = NULL, ...) } \arguments{ \item{name}{(character) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 plant species growth forms by taxon name, IUCN id, and region } \examples{ \dontrun{ rl_growth_forms('Quercus robur') rl_growth_forms('Quercus robur', region = 'europe') rl_growth_forms(id = 63532) rl_growth_forms(id = 63532, region = 'europe') rl_growth_forms('Mucuna bracteata') rl_growth_forms('Abarema villifera') rl_growth_forms('Adansonia perrieri') rl_growth_forms('Adenostemma harlingii') rl_growth_forms_('Quercus robur') rl_growth_forms_(id = 63532, region = 'europe') } } \references{ API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} } rredlist/man/rredlist-package.Rd0000644000175100001440000000457713150120021016401 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rredlist-package.R \docType{package} \name{rredlist-package} \alias{rredlist-package} \alias{rredlist} \title{rredlist - IUCN Red List Client} \description{ rredlist - IUCN Red List Client } \section{Taxonomic Names vs. IUCN IDs}{ From the documentation (quoting): "It is advisable wherever possible to use the taxon name (species name) to make your API calls, rather than using IDs. IDs are not immovable are expected to be used mainly by organisations that work closely with the IUCN Red List." } \section{Authentication}{ IUCN requires you to get your own API key, an alphanumeric string that you need to send in every request. Get it at \url{http://apiv3.iucnredlist.org/api/v3/token} Keep this key private. You can pass the key in to each function via the \code{key} parameter, but it's better to store the key either as a environment variable (\code{IUCN_REDLIST_KEY}) or an R option (\code{iucn_redlist_key}) - we suggest using the former option. } \section{High vs. Low level package APIs}{ \strong{High level API} High level functions do the HTTP request and parse data to a data.frame for ease of downstream use. The high level functions have no underscore on the end of the function name, e.g., \code{\link[=rl_search]{rl_search()}} \strong{Low level API} The parsing to data.frame in the high level API does take extra time. The low level API only does the HTTP request, and gives back JSON without doing any more parsing. The low level functions DO have an underscore on the end of the function name, e.g., \code{\link[=rl_search_]{rl_search_()}} } \section{No Spatial}{ This package does not include support for the spatial API, described at \url{http://apiv3.iucnredlist.org/spatial} } \section{Citing the Red List API}{ The citation is \code{IUCN 2015. IUCN Red List of Threatened Species. Version 2015-4 } You can get this programatically via \code{\link[=rl_citation]{rl_citation()}} } \section{Rate limiting}{ From the IUCN folks: Too many frequent calls, or too many calls per day might get your access blocked temporarily. If you're a heavy API user, the Red List Unit asked that you contact them, as there might be better options. They suggest a 2-second delay between your calls if you plan to make a lot of calls. } \author{ Scott Chamberlain \email{myrmecocystus@gmail.com} } \keyword{package} rredlist/man/rl_synonyms.Rd0000644000175100001440000000212513150120021015537 0ustar hornikusers% 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 synonym information by taxonomic name} \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. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 synonym information by taxonomic name } \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} } rredlist/man/rl_sp.Rd0000644000175100001440000000121213150120021014256 0ustar hornikusers% 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}{(integer/numeric) Page to get. Default: 1} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \description{ Get species } \examples{ \dontrun{ rl_sp(page = 3) } } rredlist/man/rl_narrative.Rd0000644000175100001440000000277613150120021015647 0ustar hornikusers% 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, IUCN id, and region} \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) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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, IUCN id, and region } \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} } rredlist/man/rl_measures.Rd0000644000175100001440000000275313150120021015473 0ustar hornikusers% 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, IUCN id, and region} \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) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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, IUCN id, and region } \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} } rredlist/man/rl_common_names.Rd0000644000175100001440000000207013150120021016312 0ustar hornikusers% 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 common names for a given taxonomic name} \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. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 common names for a given taxonomic name } \examples{ \dontrun{ rl_common_names('Loxodonta africana') rl_common_names_('Loxodonta africana') } } \references{ API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} } rredlist/man/rl_occ_country.Rd0000644000175100001440000000267113150120021016175 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rl_occ_country.R \name{rl_occ_country} \alias{rl_occ_country} \title{Get country occurrence by species name or ID} \usage{ rl_occ_country(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) } \arguments{ \item{name}{(character) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 country occurrence by species name or ID } \examples{ \dontrun{ rl_occ_country('Loxodonta africana') rl_occ_country('Fratercula arctica', region = 'europe') rl_occ_country(id = 12392) rl_occ_country(id = 22694927, region = 'europe') rl_occ_country('Fratercula arctica', parse = FALSE) rl_occ_country_('Fratercula arctica') rl_occ_country_('Fratercula arctica', region = 'europe') } } \references{ API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} } rredlist/man/rl_habitats.Rd0000644000175100001440000000304413150120021015440 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rl_habitats.R, R/rl_history.R \name{rl_habitats} \alias{rl_habitats} \alias{rl_habitats_} \alias{rl_history_} \title{Get species habitats by taxon name, IUCN id, and region} \usage{ rl_habitats(name = NULL, id = NULL, region = NULL, key = NULL, parse = TRUE, ...) rl_habitats_(name = NULL, id = NULL, region = NULL, key = NULL, ...) rl_history_(name = NULL, id = NULL, region = NULL, key = NULL, ...) } \arguments{ \item{name}{(character) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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, IUCN id, and region } \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} } rredlist/man/rl_countries.Rd0000644000175100001440000000156013150120021015655 0ustar hornikusers% 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 = TRUE, ...) rl_countries_(key = NULL, ...) } \arguments{ \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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} } rredlist/man/rl_threats.Rd0000644000175100001440000000272313150120021015316 0ustar hornikusers% 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, IUCN id, and region} \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) A taxonomic name} \item{id}{(character) An IUCN identifier} \item{region}{(character) A region name, see \code{\link{rl_regions}} for acceptable region identifiers (use the entries in the \code{identifier} column)} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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, IUCN id, and region } \examples{ \dontrun{ rl_threats('Fratercula arctica') rl_threats('Fratercula arctica', region = 'europe') rl_threats(id = 12392) rl_threats(id = 22694927, region = 'europe') rl_threats(name = 'Abies numidica') rl_threats_('Fratercula arctica') rl_threats(id = 62290750) } } \references{ API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} } rredlist/man/rl_citation.Rd0000644000175100001440000000066713150120021015463 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rl_citation.R \name{rl_citation} \alias{rl_citation} \title{Get the citation Red List API version} \usage{ rl_citation(...) } \arguments{ \item{...}{Curl options passed to \code{\link[crul:HttpClient]{crul::HttpClient()}}} } \value{ API citation as character string } \description{ Get the citation Red List API version } \examples{ \dontrun{ rl_citation() } } rredlist/man/rl_regions.Rd0000644000175100001440000000156613150120021015316 0ustar hornikusers% 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. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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} } rredlist/man/rl_sp_category.Rd0000644000175100001440000000167613150120021016171 0ustar hornikusers% 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) A two-letter category code. One of "DD", "LC", "NT", "VU", "EN", "CR", "EW", "EX", "LRlc", "LRnt", "LRcd"} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \description{ Get species by category } \examples{ \dontrun{ rl_sp_category('VU') rl_sp_category('LRlc') rl_sp_category('EN') rl_sp_category('EX') rl_sp_category('EX', parse = FALSE) rl_sp_category_('EX') } } rredlist/man/rl_version.Rd0000644000175100001440000000063713150120021015333 0ustar hornikusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rl_version.R \name{rl_version} \alias{rl_version} \title{Get the Red List API version} \usage{ rl_version(...) } \arguments{ \item{...}{Curl options passed to \code{\link[crul:HttpClient]{crul::HttpClient()}}} } \value{ API version as character string } \description{ Get the Red List API version } \examples{ \dontrun{ rl_version() } } rredlist/man/rl_sp_country.Rd0000644000175100001440000000241113150120021016043 0ustar hornikusers% 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) A two-letter country code. See \code{isocode} column in result of \code{\link[=rl_countries]{rl_countries()}} request for country codes.} \item{key}{A IUCN API token. See \url{http://apiv3.iucnredlist.org/api/v3/token} to get a 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[crul]{HttpClient}}} } \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 res <- rl_sp_country('NZ', verbose = TRUE) } } \references{ API docs at \url{http://apiv3.iucnredlist.org/api/v3/docs} } rredlist/LICENSE0000644000175100001440000000005713035447512013133 0ustar hornikusersYEAR: 2017 COPYRIGHT HOLDER: Scott Chamberlain