├── .Rbuildignore ├── .gitattributes ├── .github ├── CONTRIBUTING.md ├── issue_template.md ├── pull_request_template.md └── workflows │ └── R-check.yml ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── Makefile ├── NAMESPACE ├── NEWS.md ├── R ├── eol.R ├── flora_europaea.R ├── gisd.R ├── globals.R ├── griis.R ├── is_native.R ├── nsr.R ├── originr-package.R └── zzz.R ├── README-NOT.md ├── README.Rmd ├── README.md ├── codemeta.json ├── data ├── nsr_countries.RData └── nsr_pol_divisions.RData ├── man ├── eol.Rd ├── flora_europaea.Rd ├── gisd.Rd ├── griis.Rd ├── is_native.Rd ├── nsr.Rd ├── nsr_countries.Rd ├── nsr_pol_divisions.Rd └── originr-package.Rd ├── originr.Rproj └── tests ├── fixtures ├── flora_europaea.yml ├── flora_europaea_fail.yml ├── gisd.yml ├── gisd_not_found.yml ├── griis.yml ├── is_native.yml ├── nsr.yml └── nsr_no_results.yml ├── test-all.R └── testthat ├── helper-originr.R ├── test-eol.R ├── test-flora_europaea.R ├── test-gisd.R ├── test-griis.R ├── test-is_native.R └── test-nsr.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^CODE_OF_CONDUCT\.md$ 4 | README.Rmd 5 | .travis.yml 6 | appveyor.yml 7 | cran-comments.md 8 | man-roxygen 9 | ^cran-comments\.md$ 10 | ^codemeta\.json$ 11 | ^.github$ 12 | ^Makefile$ 13 | ^LICENSE\.md$ 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | tests/fixtures/**/* -diff 3 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING # 2 | 3 | ### Bugs? 4 | 5 | * Submit an issue on the [Issues page](https://github.com/ropensci/originr/issues) 6 | 7 | ### Issues and Pull Requests 8 | 9 | If you are considering a pull request, you may want to open an issue first to discuss with the maintainer(s). 10 | 11 | ### Code contributions 12 | 13 | * Fork this repo to your GitHub account 14 | * Clone your version on your account down to your machine from your account, e.g,. `git clone https://github.com//originr.git` 15 | * Make sure to track progress upstream (i.e., on our version of `originr` at `ropensci/originr`) by doing `git remote add upstream https://github.com/ropensci/originr.git`. Before making changes make sure to pull changes in from upstream by doing either `git fetch upstream` then merge later or `git pull upstream` to fetch and merge in one step 16 | * Make your changes (bonus points for making changes on a new feature branch - see for how to contribute by branching, making changes, then submitting a pull request) 17 | * Push up to your account 18 | * Submit a pull request to home base (likely master branch, but check to make sure) at `ropensci/originr` 19 | 20 | ### Discussion forum 21 | 22 | Check out our [discussion forum](https://discuss.ropensci.org) if you think your issue requires a longer form discussion. 23 | 24 | ### Prefer to Email? 25 | 26 | Email the person listed as maintainer in the `DESCRIPTION` file of this repo. 27 | 28 | Though note that private discussions over email don't help others - of course email is totally warranted if it's a sensitive problem of any kind. 29 | 30 | ### Thanks for contributing! 31 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
Session Info 6 | 7 | ```r 8 | 9 | ``` 10 |
11 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ## Description 8 | 9 | 10 | ## Related Issue 11 | 14 | 15 | ## Example 16 | 18 | 19 | 21 | 22 | -------------------------------------------------------------------------------- /.github/workflows/R-check.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | 3 | name: R-check 4 | 5 | jobs: 6 | R-check: 7 | runs-on: ${{ matrix.config.os }} 8 | 9 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 10 | 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | config: 15 | - { os: windows-latest, r: 'latest'} 16 | - { os: macOS-latest, r: 'oldrel'} 17 | - { os: macOS-latest, r: 'latest'} 18 | - { os: macOS-latest, r: 'devel'} 19 | - { os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 20 | - { os: ubuntu-16.04, r: 'latest', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 21 | 22 | env: 23 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true 24 | CRAN: ${{ matrix.config.rspm }} 25 | 26 | steps: 27 | - uses: actions/checkout@v2 28 | 29 | - uses: r-lib/actions/setup-r@v1 30 | with: 31 | r-version: ${{ matrix.config.r }} 32 | 33 | - uses: r-lib/actions/setup-pandoc@v1 34 | 35 | - name: Install pak 36 | run: | 37 | install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") 38 | shell: Rscript {0} 39 | 40 | - name: Cache R packages 41 | uses: actions/cache@v2 42 | with: 43 | path: ${{ env.R_LIBS_USER }} 44 | key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }} 45 | 46 | - name: Install system dependencies 47 | if: runner.os == 'Linux' 48 | env: 49 | RHUB_PLATFORM: linux-x86_64-ubuntu-gcc 50 | run: | 51 | while read -r cmd 52 | do 53 | eval sudo $cmd 54 | done < <(Rscript -e 'writeLines(pak::local_system_requirements("ubuntu", "16.04"))') 55 | 56 | - name: Install dependencies 57 | run: | 58 | pak::local_install_dev_deps() 59 | pak::pkg_install(c("rcmdcheck")) 60 | shell: Rscript {0} 61 | 62 | - name: Session info 63 | run: | 64 | options(width = 100) 65 | pkgs <- installed.packages()[, "Package"] 66 | sessioninfo::session_info(pkgs, include_base = TRUE) 67 | shell: Rscript {0} 68 | 69 | - name: Check 70 | run: Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')" 71 | 72 | - name: Upload check results 73 | if: failure() 74 | uses: actions/upload-artifact@v2 75 | with: 76 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 77 | path: check 78 | 79 | - name: Test coverage 80 | if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'latest' 81 | run: | 82 | Rscript -e "install.packages('covr')" -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")' 83 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | cran-comments.md 5 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: originr 2 | Type: Package 3 | Title: Fetch Species Origin Data from the Web 4 | Description: Get species origin data (whether species is native/invasive) from the 5 | following sources on the web: Encyclopedia of Life (), Flora 6 | 'Europaea' (), Global Invasive Species 7 | Database (), the Native Species Resolver 8 | (), Integrated Taxonomic 9 | Information Service (), and Global Register of 10 | Introduced and Invasive Species (). 11 | Version: 0.4.0.91 12 | Authors@R: c( 13 | person("Scott", "Chamberlain", role = c("aut", "cre"), 14 | email = "myrmecocystus@gmail.com", comment = c(ORCID="0000-0003-1444-9135")), 15 | person("Ignasi", "Bartomeus", role = "aut", email = "nacho.bartomeus@gmail.com") 16 | ) 17 | License: MIT + file LICENSE 18 | URL: https://docs.ropensci.org/originr/, https://github.com/ropensci/originr 19 | BugReports: https://github.com/ropensci/originr/issues 20 | Roxygen: list(markdown = TRUE) 21 | Encoding: UTF-8 22 | LazyLoad: yes 23 | LazyData: yes 24 | Imports: 25 | crul, 26 | jsonlite, 27 | data.table, 28 | xml2, 29 | taxize (>= 0.9.0) 30 | Suggests: 31 | testthat, 32 | vcr 33 | RoxygenNote: 7.1.0 34 | X-schema.org-applicationCategory: Biology 35 | X-schema.org-keywords: species, native, invasive, origin, web, API, eol, gisd, nsr, itis, griis 36 | X-schema.org-isPartOf: https://ropensci.org 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2020 2 | COPYRIGHT HOLDER: originr authors 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2020 originr authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PACKAGE := $(shell grep '^Package:' DESCRIPTION | sed -E 's/^Package:[[:space:]]+//') 2 | RSCRIPT = Rscript --no-init-file 3 | 4 | all: move rmd2md 5 | 6 | move: 7 | cp inst/vign/vcr.md vignettes;\ 8 | cp inst/vign/configuration.md vignettes 9 | 10 | rmd2md: 11 | cd vignettes;\ 12 | mv vcr.md vcr.Rmd;\ 13 | mv configuration.md configuration.Rmd 14 | 15 | install: doc build 16 | R CMD INSTALL . && rm *.tar.gz 17 | 18 | build: 19 | R CMD build . 20 | 21 | doc: 22 | ${RSCRIPT} -e "devtools::document()" 23 | 24 | eg: 25 | ${RSCRIPT} -e "devtools::run_examples(run = TRUE)" 26 | 27 | test: 28 | ${RSCRIPT} -e "devtools::test()" 29 | 30 | check: build 31 | _R_CHECK_CRAN_INCOMING_=FALSE R CMD CHECK --as-cran --no-manual `ls -1tr ${PACKAGE}*gz | tail -n1` 32 | @rm -f `ls -1tr ${PACKAGE}*gz | tail -n1` 33 | @rm -rf ${PACKAGE}.Rcheck 34 | 35 | check_windows: 36 | ${RSCRIPT} -e "devtools::check_win_devel(); devtools::check_win_release()" 37 | 38 | readme: 39 | ${RSCRIPT} -e "knitr::knit('README.Rmd')" 40 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(eol) 4 | export(eol_invasive_data) 5 | export(flora_europaea) 6 | export(gisd) 7 | export(griis) 8 | export(is_native) 9 | export(nsr) 10 | importFrom(crul,HttpClient) 11 | importFrom(data.table,rbindlist) 12 | importFrom(data.table,setDF) 13 | importFrom(jsonlite,fromJSON) 14 | importFrom(taxize,classification) 15 | importFrom(taxize,get_tsn) 16 | importFrom(taxize,get_uid) 17 | importFrom(taxize,itis_native) 18 | importFrom(xml2,read_xml) 19 | importFrom(xml2,xml_find_all) 20 | importFrom(xml2,xml_text) 21 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | originr 0.4.0 2 | ============= 3 | 4 | ### MINOR IMPROVEMENTS 5 | 6 | * parameter name changed in `taxize::get_tsn()` - fixed accordingly here (#25) 7 | * now using vcr for test http request caching (#26) 8 | 9 | 10 | originr 0.3.0 11 | ============= 12 | 13 | ### NEW FEATURES 14 | 15 | * replaced HTTP clients, now using `crul` package (#13) 16 | * new function `eol_invasive_data()` to get the global data.frame of invasive species data from EOL. 17 | 18 | ### MINOR IMPROVEMENTS 19 | 20 | * Improved documentation around `eol()` behavior. `dataset="all"` does not encompass, or at least does not include data to indicate that it encompasses, the individual EOL invasives datasets. There's no response from EOL on this, so we're stuck with the behavior (#10) (#18) 21 | * Added internal datasets for `nsr()` function. Now internally we check whether the country, and state/province name passed in is in the acceptable set, and throw warning if not (#19) 22 | 23 | 24 | originr 0.2.0 25 | ============= 26 | 27 | ### NEW FEATURES 28 | 29 | * Added a new data source: Global Register of Introduced and Invasive 30 | Species (GRIIS). See `griis()` (#5) (#7) 31 | 32 | ### BUG FIXES 33 | 34 | * Fix to `flora_europaea()` to convert factors to character and 35 | to stop with meaningful message when more than one species 36 | passed in (#8) 37 | 38 | 39 | originr 0.1.0 40 | ============= 41 | 42 | ### NEW FEATURES 43 | 44 | * Released to CRAN. 45 | -------------------------------------------------------------------------------- /R/eol.R: -------------------------------------------------------------------------------- 1 | #' Search for presence of taxonomic names in EOL invasive species databases. 2 | #' 3 | #' See Details for important information. 4 | #' 5 | #' @export 6 | #' @param name A taxonomic name, or a vector of names. 7 | #' @param dataset One of all, gisd100, gisd, isc, daisie, i3n, or mineps. 8 | #' See the Details for what each dataset ID. 9 | #' @param searchby One of 'grep' (exact match) or 'agrep' (fuzzy match) 10 | #' @param page A maximum of 30 results are returned per page. This parameter 11 | #' allows you to fetch more pages of results if there are more than 30 matches 12 | #' (Default: 1) 13 | #' @param per_page Results to get per page. Default: 500 14 | #' @param key Your EOL API key; loads from .Rprofile. 15 | #' @param messages (logical) If \code{TRUE} the actual taxon queried is printed 16 | #' on the console. 17 | #' @param count (logical) If TRUE, give back a count of number of taxa listed 18 | #' as invasive, if \code{FALSE} (default), the normal output is given. 19 | #' @param ... curl options passed on to \code{\link[crul]{HttpClient}} 20 | #' 21 | #' @details 22 | #' `eol_invasive_data()` gives you the entire data.frame from 23 | #' the "dataset=all", while `eol()` let's you search on a vector of names 24 | #' against any of the datasets 25 | #' 26 | #' IMPORTANT: note that setting `dataset="all"` will give you surprising results. 27 | #' EOL does not include informaiton on which of the invasive datasets (i.e., gisd100, 28 | #' gisd, isc, daisie, i3n, or mineps) the taxon is found in, and sometimes e.g., if 29 | #' taxon X is in GISD, you might not find it in "all", weird. I don't know 30 | #' why that's happening, but it shouldn't happen. 31 | #' 32 | #' IMPORTANT: When you get a returned NaN for a taxon, that means it's not on 33 | #' the invasive list in question. If the taxon is found, a taxon identifier 34 | #' is returned. 35 | #' 36 | #' Beware that some datasets are quite large, and may take 30 sec to a minute to 37 | #' pull down all data before we can search for your species. Note there is no 38 | #' parameter in this API method for searching by taxon name. 39 | #' 40 | #' `eol()` is vectorized, so you can pass a single name or a vector 41 | #' of names. 42 | #' 43 | #' It's possible to return JSON or XML with the EOL API. However, this function 44 | #' only returns JSON. 45 | #' 46 | #' Options for the dataset parameter are 47 | #' 48 | #' - all - All datasets 49 | #' - gisd100 - 100 of the World's Worst Invasive Alien Species 50 | #' (Global Invasive Species Database) https://eol.org/resources/477 51 | #' - gisd - Global Invasive Species Database 2013 52 | #' http://eol.org/collections/54983 53 | #' - isc - Centre for Agriculture and Biosciences International Invasive 54 | #' Species Compendium (ISC) http://eol.org/collections/55180 55 | #' - daisie - Delivering Alien Invasive Species Inventories for Europe 56 | #' (DAISIE) Species List http://eol.org/collections/55179 57 | #' - i3n - IABIN Invasives Information Network (I3N) Species 58 | #' http://eol.org/collections/55176 59 | #' - mineps - Marine Invaders of the NE Pacific 60 | #' Species http://eol.org/collections/55331 61 | #' 62 | #' Datasets are not updated that often. Here's last updated dates for some of 63 | #' the datasets as of 2014-08-25 64 | #' 65 | #' - gisd100 updated 6 mos ago 66 | #' - gisd updated 1 yr ago 67 | #' - isc updated 1 yr ago 68 | #' - daisie updated 1 yr ago 69 | #' - i3n updated 1 yr ago 70 | #' - mineps updated 1 yr ago 71 | #' 72 | #' @return A list of data.frame's/strings with results, with each element 73 | #' named by the input elements to the name parameter. 74 | #' 75 | #' @examples \dontrun{ 76 | #' eol(name='Brassica oleracea', dataset='gisd') 77 | #' eol(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata', 78 | #' 'Pinus concolor'), dataset='gisd') 79 | #' eol(name='Sargassum', dataset='gisd') 80 | #' eol(name='Ciona intestinalis', dataset='mineps') 81 | #' eol(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata', 82 | #' 'Pinus concolor'), dataset='i3n') 83 | #' eol(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'), 84 | #' dataset='daisie') 85 | #' eol(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'), 86 | #' dataset='isc') 87 | #' 88 | #' # Count 89 | #' eol(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata', 90 | #' 'Pinus concolor'), dataset='gisd', count = TRUE) 91 | #' 92 | #' # curl options 93 | #' eol(name='Sargassum', dataset='gisd', verbose = TRUE) 94 | #' } 95 | eol <- function(name, dataset="all", searchby = grep, page=NULL, 96 | per_page=500, key = NULL, messages=TRUE, count=FALSE, ...) { 97 | 98 | if (any(nchar(name) < 1)) stop("'name' must be longer than 0 characters") 99 | if (is.null(dataset)) stop("please provide a dataset name") 100 | datasetid <- switch(dataset, 101 | all = 55367, 102 | gisd100 = 54500, 103 | gisd = 54983, 104 | isc = 55180, 105 | daisie = 55179, 106 | i3n = 55176, 107 | mineps = 55331) 108 | 109 | args <- orc(list(page = page, per_page = 500, filter = 'taxa')) 110 | path <- sprintf("/api/collections/1.0/%s.json", datasetid) 111 | 112 | cli <- crul::HttpClient$new(url = 'http://eol.org', 113 | opts = list(...)) 114 | tt <- cli$get(path, query = args) 115 | tt$raise_for_status() 116 | res <- jsonlite::fromJSON(tt$parse("UTF-8"), FALSE) 117 | data_init <- res$collection_items 118 | mssg(messages, sprintf("Getting data for %s names...", res$total_items)) 119 | 120 | pages_get <- pages_left(res) 121 | 122 | if (!is.null(pages_get)) { 123 | out <- list() 124 | for (i in pages_get) { 125 | args <- orc(list(page = i, per_page = 500, filter = 'taxa')) 126 | tt <- cli$get(path, query = args) 127 | tt$raise_for_status() 128 | res <- jsonlite::fromJSON(tt$parse("UTF-8"), FALSE) 129 | out[[i]] <- res$collection_items 130 | } 131 | res2 <- orc(out) 132 | dat_all <- do.call(c, list(data_init, do.call(c, res2))) 133 | dat_all <- lapply(dat_all, "[", c("name", "object_id")) 134 | dat <- todf(dat_all) 135 | } else { 136 | dat_all <- lapply(data_init, "[", c("name","object_id")) 137 | dat <- todf(dat_all) 138 | } 139 | 140 | # search by name 141 | tmp <- stats::setNames(lapply(name, getmatches, y = searchby, z = dat), name) 142 | df <- do.call("rbind.data.frame", 143 | Map(function(x,y) { 144 | data.frame(id = y, x, stringsAsFactors = FALSE) 145 | }, tmp, names(tmp))) 146 | df$db <- dataset 147 | names(df)[c(1,3)] <- c("searched_name","eol_object_id") 148 | row.names(df) <- NULL 149 | if (NROW(df) > 0) df <- df[!duplicated(df), ] 150 | if (!count) df else length(stats::na.omit(df$eol_object_id)) 151 | } 152 | 153 | pages_left <- function(x) { 154 | tot <- x$total_items 155 | got <- length(x$collection_items) 156 | if (got < tot) { 157 | seq(1, ceiling((tot - got)/500), 1) + 1 158 | } 159 | } 160 | 161 | getmatches <- function(x, y, z) { 162 | matched <- eval(y)(x, z$name) 163 | if (identical(matched, integer(0))) { 164 | dff <- data.frame(name = x, object_id = NaN, stringsAsFactors = FALSE) 165 | dff$name <- as.character(dff$name) 166 | dff 167 | } else { 168 | z[matched, ] 169 | } 170 | } 171 | 172 | #' @export 173 | #' @rdname eol 174 | eol_invasive_data <- function(...) { 175 | args <- orc(list(per_page = 500, filter = 'taxa')) 176 | path <- "/api/collections/1.0/55367.json" 177 | cli <- crul::HttpClient$new(url = 'http://eol.org', 178 | opts = list(...)) 179 | tt <- cli$get(path, query = args) 180 | tt$raise_for_status() 181 | res <- jsonlite::fromJSON(tt$parse("UTF-8"), FALSE) 182 | data_init <- res$collection_items 183 | message(sprintf("Getting data for %s names...", res$total_items)) 184 | 185 | pages_get <- pages_left(res) 186 | 187 | if (!is.null(pages_get)) { 188 | out <- list() 189 | for (i in pages_get) { 190 | args <- orc(list(page = i, per_page = 500, filter = 'taxa')) 191 | tt <- cli$get(path, query = args) 192 | tt$raise_for_status() 193 | res <- jsonlite::fromJSON(tt$parse("UTF-8"), FALSE) 194 | out[[i]] <- res$collection_items 195 | } 196 | res2 <- orc(out) 197 | dat_all <- do.call(c, list(data_init, do.call(c, res2))) 198 | dat_all <- lapply(dat_all, "[", c("name", "object_id")) 199 | dat <- todf(dat_all) 200 | } else { 201 | dat_all <- lapply(data_init, "[", c("name","object_id")) 202 | dat <- todf(dat_all) 203 | } 204 | return(dat) 205 | } 206 | 207 | -------------------------------------------------------------------------------- /R/flora_europaea.R: -------------------------------------------------------------------------------- 1 | #' Check species status (native/exotic) in Flora Europaea 2 | #' 3 | #' @export 4 | #' 5 | #' @param sp character; a vector of length one with a single scientific 6 | #' species names in the form of \code{c("Genus species")}. 7 | #' @param messages logical; If \code{TRUE} (default), informative messages 8 | #' printed 9 | #' @param ... curl options passed on to \code{\link[crul]{HttpClient}} 10 | #' @return A list of vectors containing the countries where the species is 11 | #' native, exotic, ... 12 | #' 13 | #' @description This function check the status (native or exotic) of a species 14 | #' in each of the eu countries. 15 | #' 16 | #' For that end, it checks Flora Europaea (http://rbg-web2.rbge.org.uk/FE/fe.html) 17 | #' and scrapes the data from there. 18 | #' 19 | #' Note that the webpage contains more information. 20 | #' 21 | #' As expected, the function is as good as the database is. I think for 22 | #' native species is robust but new exotic species are not added as to my 23 | #' knowledge the database is not updated anymore. The database is not able to 24 | #' recognize species synonyms. 25 | #' 26 | #' See \url{http://rbg-web2.rbge.org.uk/FE/data/countries} for explanation 27 | #' of the database codes. 28 | #' 29 | #' @author Ignasi Bartomeus \email{nacho.bartomeus@@gmail.com} 30 | #' @examples \dontrun{ 31 | #' sp <- c("Lavandula stoechas", "Carpobrotus edulis", "Rhododendron ponticum", 32 | #' "Alkanna lutea", "Anchusa arvensis") 33 | #' flora_europaea(sp[1]) 34 | #' sapply(sp, flora_europaea, simplify = FALSE) 35 | #' 36 | #' flora_europaea('Calendula officinalis') 37 | #' } 38 | #' 39 | flora_europaea <- function(sp, messages = TRUE, ...) { 40 | #reformat sp list 41 | if (length(sp) > 1) { 42 | stop("sp should be a single species", call. = FALSE) 43 | } 44 | sp <- as.character(sp) 45 | genus <- strsplit(sp, " ")[[1]][1] 46 | species <- strsplit(sp, " ")[[1]][2] 47 | #create urls to parse 48 | url <- "http://rbg-web2.rbge.org.uk/cgi-bin/nph-readbtree.pl/feout" 49 | args <- list(FAMILY_XREF = "", GENUS_XREF = genus, 50 | SPECIES_XREF = species, TAXON_NAME_XREF = "", RANK = "") 51 | mssg(messages, paste("Checking", sp)) 52 | #Parse url and extract table 53 | cli <- crul::HttpClient$new(url = url, opts = list(...)) 54 | url_check <- cli$get(query = args) 55 | warn_status(url_check) 56 | doc <- xml2::read_html(url_check$parse("UTF-8"), encoding = "UTF-8") 57 | tables <- xml2::xml_find_all(doc, "//table") 58 | 59 | if (length(tables) < 3) { 60 | mssg(messages, "Species not found") 61 | NULL 62 | } else { 63 | for(i in seq_along(tables)){ 64 | text <- xml_text(tables[[i]], trim = FALSE) 65 | if (grepl("Distribution:", text, perl = TRUE)) {break} 66 | } 67 | if (!grepl("Distribution:", text, perl = TRUE)) { 68 | mssg(messages, "Species with no distribution. Probably not native.") 69 | } else{ 70 | m_nat <- regexpr("Distribution: [A-Za-z ()?*%,]*", text, perl = TRUE) 71 | distr_nat <- regmatches(text, m_nat) 72 | distr_status <- regmatches(distr_nat, 73 | gregexpr("[*][A-Z][a-z]", distr_nat, perl = TRUE)) # * Status doubtful; possibly native 74 | distr_occ <- regmatches(distr_nat, 75 | gregexpr("[?][A-Z][a-z]", distr_nat, perl = TRUE)) # ? Occurrence doubtful 76 | distr_ext <- regmatches(distr_nat, 77 | gregexpr("[%][A-Z][a-z]", distr_nat, perl = TRUE)) # % Extinct 78 | #also deal with Rs(N) extract e.g. Rs(N,B,C,W,K,E) 79 | distr_nat <- gsub(",", " ", distr_nat) 80 | distr_nat <- gsub("(", " ", distr_nat, fixed = TRUE) 81 | distr_nat <- gsub(")", "", distr_nat, fixed = TRUE) 82 | distr_nat <- gsub("Distribution: ", "", distr_nat) 83 | 84 | nat = exo = stat = oc = ex = NA 85 | if (distr_nat != "") { 86 | native <- strsplit(distr_nat, " ")[[1]] 87 | delete <- which(!native %in% country$short) 88 | if (length(delete) > 0) native <- native[-delete] 89 | nat <- sapply(native, function(x) {country[which(x == country$short), "long"]}) 90 | } 91 | if (length(distr_status[[1]]) > 0) { 92 | status <- gsub("*", "", distr_status[[1]], fixed = TRUE) 93 | stat <- sapply(status, function(x) {country[which(x == country$short), "long"]}) 94 | } 95 | if (length(distr_occ[[1]]) > 0) { 96 | occ <- gsub("?", "", distr_occ[[1]], fixed = TRUE) 97 | oc <- sapply(occ, function(x) {country[which(x == country$short), "long"]}) 98 | } 99 | if (length(distr_ext[[1]]) > 0) { 100 | ext <- gsub("%", "", distr_ext[[1]], fixed = TRUE) 101 | ex <- sapply(ext, function(x) {country[which(x == country$short), "long"]}) 102 | } 103 | #extract exotics 104 | m_ex <- regexpr("[[][A-Za-z ()?*%,]*", text, perl = TRUE) 105 | distr_exot <- regmatches(text, m_ex) 106 | if (length(distr_exot) > 0) { 107 | #NEED TO ADD * ? % for exotics? I don't think those cases exist. Maybe ? 108 | exotic <- strsplit(gsub("[", "", distr_exot, fixed = TRUE), " ")[[1]] 109 | exo <- sapply(exotic, function(x) {country[which(x == country$short), "long"]}) 110 | } 111 | list(native = as.character(nat), exotic = as.character(exo), status_doubtful = as.character(stat), 112 | occurrence_doubtful = as.character(oc), extinct = as.character(ex)) 113 | } 114 | } 115 | } 116 | 117 | #add country short-names translation cheat sheet as dataframe 118 | country <- data.frame(short = c("Al", "Au", "Az", "Be", "Bl", "Br", "Bu", "Co", "Cr", "Cz", 119 | "Da", "Fa", "Fe", "Ga", "Ge", "Gr", "Hb", 120 | "He", "Ho", "Hs", "Hu", "Is", "It", "Ju", 121 | "Lu", "No", "Po", "Rm", "Rs", "Sa","Sb", 122 | "Si", "Su", "Tu", "N", "B", "C", 123 | "W", "K", "E"), 124 | long = c("Albania", "Austria", "Azores", "Belgium", "Islas_Baleares", 125 | "Britain", "Bulgaria", "Corse", "Kriti", 126 | "Czechoslovakia", "Denmark", "Faroer", 127 | "Finland", "France", "Germany", "Greece", 128 | "Ireland", "Switzerland", "Netherlands", "Spain", 129 | "Hungary", "Iceland", "Italy", "Jugoslavia", 130 | "Portugal", "Norway", "Poland", "Romania", 131 | "USSR", "Sardegna", "Svalbard", "Sicilia", 132 | "Sweden", "Turkey", "USSR_Northern_Division", 133 | "USSR_Baltic_Division", "USSR_Central_Division", 134 | "USSR_South_western", "USSR_Krym", 135 | "USSRSouth_eastern_Division"), 136 | stringsAsFactors = FALSE) 137 | -------------------------------------------------------------------------------- /R/gisd.R: -------------------------------------------------------------------------------- 1 | #' Check invasive species status for a set of species from GISD database 2 | #' 3 | #' @export 4 | #' 5 | #' @param x character; a vector of scientific species names in the form of 6 | #' c("Genus species"). 7 | #' @param simplify logical; returns a data.frame with the species name and the 8 | #' values "Invasive", "Not in GISD". I recomend to check first the not 9 | #' simplified version (default), which contains raw information about the 10 | #' level of invasiveness. 11 | #' @param messages logical; If \code{TRUE} (default), informative messages 12 | #' printed. 13 | #' @param ... curl options passed on to \code{\link[crul]{HttpClient}} 14 | #' 15 | #' @return A list with species names, native range countries, and invasive 16 | #' range countries 17 | #' 18 | #' @description This function check which species (both plants and animals) are 19 | #' considered "invaders" somewhere in the world. 20 | #' 21 | #' For that end, it checks GISD (http://www.iucngisd.org/gisd) and 22 | #' returns a value, either "Not in GISD" or the brief description presented in 23 | #' GISD. 24 | #' 25 | #' Note that the webpage contains more information. Also note that the function 26 | #' won't tell you if it's exotic in your area, a lot of exotic species are not 27 | #' considered invaders (yet). 28 | #' 29 | #' As expected, the function is as good as the database is, which I find quite 30 | #' reliable and well maintained. 31 | #' The database is also able to recognize a lot (but not all) of the species 32 | #' synonyms. 33 | #' 34 | #' Note that \code{\link{eol}} with source of gisd or gisd100 may end up with 35 | #' different results as this function goes directly to the GISD website, whereas 36 | #' EOL only updates their GISD data occassionally. See notes in \code{\link{eol}}. 37 | #' 38 | #' @author Ignasi Bartomeus \email{nacho.bartomeus@@gmail.com} 39 | #' @examples \dontrun{ 40 | #' sp <- c("Carpobrotus edulis", "Rosmarinus officinalis") 41 | #' ## first species is invasive, second one is not. 42 | #' gisd(sp) 43 | #' gisd(sp, simplify = TRUE) 44 | #' 45 | #' sp <- c("Carpobrotus edulis", "Rosmarinus officinalis", "Acacia mangium", 46 | #' "Archontophoenix cunninghamiana", "Antigonon leptopus") 47 | #' gisd(sp) 48 | #' gisd(sp, simplify = TRUE) 49 | #' } 50 | gisd <- function(x, simplify = FALSE, messages = TRUE, ...) { 51 | outlist <- list() 52 | for (i in seq_along(x)) { 53 | mssg(messages, paste("Checking", x[i])) 54 | out <- gbif_find(x[i], ...) 55 | if (length(out) == 0) { 56 | outlist[[i]] <- list(species = x[i], status = "Not in GISD") 57 | } else{ 58 | #Parse url and extract table 59 | doc <- xml2::read_html(paste0(gisd_base(), out$taxonID)) 60 | if (!simplify) { 61 | alien <- gsub("^\\s+|\\s+$", "", gsub("\\[|\\]|[[:digit:]]", "", xml_text(xml_find_all(doc, '//div[@id="ar-col"]//ul/li')))) 62 | native <- gsub("^\\s+|\\s+$", "", xml_text(xml_find_all(doc, '//div[@id="nr-col"]//ul/li'))) 63 | outlist[[i]] <- list(species = x[i], alien_range = alien, native_range = native) 64 | } else { 65 | outlist[[i]] <- list(species = x[i], status = "Invasive") 66 | } 67 | } 68 | } 69 | names(outlist) <- x 70 | mssg(messages, "Done") 71 | return(outlist) 72 | } 73 | 74 | gbif_find <- function(x, ...) { 75 | args <- list(datasetKey = 'b351a324-77c4-41c9-a909-f30f77268bc4', name = x) 76 | cli <- crul::HttpClient$new(url = "https://api.gbif.org", opts = list(...)) 77 | out <- cli$get("v1/species", query = args) 78 | out$raise_for_status() 79 | fromJSON(out$parse("UTF-8"))$results 80 | } 81 | 82 | gisd_base <- function() "http://www.iucngisd.org/gisd/species.php?sc=" 83 | -------------------------------------------------------------------------------- /R/globals.R: -------------------------------------------------------------------------------- 1 | if (getRversion() >= "2.15.1") { 2 | utils::globalVariables(c('nsr_countries','nsr_pol_divisions')) 3 | } 4 | -------------------------------------------------------------------------------- /R/griis.R: -------------------------------------------------------------------------------- 1 | #' Check invasive species status for a species from GRIIS database 2 | #' 3 | #' @export 4 | #' 5 | #' @param name character; a string with the scientific species name in the 6 | #' form of "Genus species". Default is NULL: return all records. 7 | #' @param impacts character; "Yes" for returning only records with impacts. 8 | #' Default to NULL: return all records. 9 | #' @param verified character; "Yes" for returning only verified records. 10 | #' Default to NULL: return all records. 11 | #' @param country character containing a valid name of a country for which to 12 | #' filter the results. Default to NULL: return all records. 13 | #' @param kindom character containing a valid name of a kindom (plantae, 14 | #' animalia, fungi, protozoa, chromista, others, ) for which to filter the 15 | #' results. Default to NULL: return all records. 16 | #' @param type character containing a valid name of a environment type 17 | #' (terrestrial, freshwater, marine, brackish, host) for which to filter 18 | #' the results. Default to NULL: return all records. 19 | #' @param ... curl options passed on to \code{\link[crul]{HttpClient}} 20 | #' @return A data.frame with species names, country where recorded, 21 | #' origin and source among other fields. 22 | #' 23 | #' @note It seems as 'name' overrides 'kindom', which means records from a 24 | #' a plant species will be returned even if kindom is set to animalia. 25 | #' 26 | #' @description This retrieves information from GRIIS (http://www.griis.org/) 27 | #' and returns all the queried records. As other functions in this package, the 28 | #' function is as good as the database is. 29 | #' 30 | #' @author Ignasi Bartomeus \email{nacho.bartomeus@@gmail.com} 31 | #' @examples \dontrun{ 32 | #' griis(name = "Carpobrotus edulis") 33 | #' griis(name = "Carpobrotus edulis", country = "Portugal") 34 | #' } 35 | #' 36 | griis <- function(name = NULL, impacts = NULL, verified = NULL, country = NULL, 37 | kindom = NULL, type = NULL, ...){ 38 | #country is well spelled 39 | countries <- c("Afghanistan", 40 | "Albania", 41 | "Algeria", 42 | "Andorra", 43 | "Angola", 44 | "Antigua and Barbuda", 45 | "Argentina", 46 | "Armenia", 47 | "Bangladesh", 48 | "Barbados", 49 | "Belarus", 50 | "Belgium", 51 | "Belize", 52 | "Benin", 53 | "Bhutan", 54 | "Bolivia", 55 | "Bosnia and Herzegovina", 56 | "Botswana", 57 | "Brazil", 58 | "Brunei Darussalam", 59 | "Bulgaria", 60 | "Burkina Faso", 61 | "Burundi", 62 | "Cabo Verde", 63 | "Cambodia", 64 | "Cameroon", 65 | "Canada", 66 | "C\u00f4te d'Ivoire", 67 | "Central African Republic", 68 | "Chad", 69 | "Chile", 70 | "China", 71 | "Colombia", 72 | "Comoros", 73 | "Cook Islands", 74 | "Croatia", 75 | "Cuba", 76 | "Cyprus", 77 | "Democratic Republic of the Congo", 78 | "Denmark", 79 | "Djibouti", 80 | "Egypt", 81 | "Equatorial Guinea", 82 | "Eritrea", 83 | "Ethiopia", 84 | "Finland", 85 | "Gabon", 86 | "Gambia (the)", 87 | "Germany", 88 | "Ghana", 89 | "Greece", 90 | "Guinea-Bissau", 91 | "Guyana", 92 | "Iceland", 93 | "Indonesia", 94 | "Iran (Islamic Republic of)", 95 | "Ireland", 96 | "Jamaica", 97 | "Japan", 98 | "Jordan", 99 | "Kenya", 100 | "Lao People's Democratic Republic", 101 | "Latvia", 102 | "Libya", 103 | "Lithuania", 104 | "Mali", 105 | "Marshall Islands", 106 | "Mauritania", 107 | "Mongolia", 108 | "Montegero", 109 | "Montenegro", 110 | "Morocco", 111 | "Mozambique", 112 | "Myanmar", 113 | "Nepal", 114 | "New Zealand", 115 | "Niger", 116 | "Nigeria", 117 | "Norway", 118 | "Pakistan", 119 | "Paraguay", 120 | "Peru", 121 | "Poland", 122 | "Portugal", 123 | "Republic of Moldova", 124 | "Romania", 125 | "Rwanda", 126 | "Saint Kitts and Nevis", 127 | "Saint Vicent and the Grenadines", 128 | "Sao Tome and Principe", 129 | "Saudi Arabia", 130 | "Senegal", 131 | "Serbia", 132 | "Seychelles", 133 | "Sierra Leone", 134 | "Singapore", 135 | "Slovakia", 136 | "Somalia", 137 | "South Africa", 138 | "South Sudan", 139 | "Spain", 140 | "Sri Lanka", 141 | "Sudan", 142 | "Suriname", 143 | "Swaziland", 144 | "Switzerland", 145 | "Taiwan", 146 | "Thailand", 147 | "The former Yugoslav Republic of Macedonia", 148 | "Togo", 149 | "Tunisia", 150 | "Turkey", 151 | "Uganda", 152 | "Ukraine", 153 | "United Arab Emirates", 154 | "United Republic of Tanzania", 155 | "Uruguay", 156 | "Venezuela", 157 | "Viet Nam", 158 | "Yemen", 159 | "Zambia", 160 | "Zimbabwe") 161 | if(!is.null(country)){ 162 | if(!country %in% countries){ 163 | stop(paste("country should be one of", paste(countries, collapse = ", "))) 164 | } 165 | } 166 | #Kinndom is valid 167 | if(!is.null(kindom)){ 168 | if(!kindom %in% c("animalia", "plantae", "fungi", 169 | "protozoa", "chromista", "others")){ 170 | stop("kindom should be one of animalia, plantae, fungi, 171 | protozoa, chromista, others") 172 | } 173 | } 174 | #verification is Yes or NULL 175 | if(!is.null(verified)){ 176 | if(!verified %in% c("Yes")){ 177 | stop("verified should be Yes or NULL") 178 | } 179 | verified <- ifelse(verified == "Yes", "1", "") 180 | } 181 | #impacts is Yes or NULL 182 | if(!is.null(impacts)){ 183 | if(!impacts %in% c("Yes")){ 184 | stop("impacts should be Yes or NULL") 185 | } 186 | impacts <- ifelse(impacts == "Yes", "1", "") 187 | } 188 | #type is terrestrial... 189 | if(!is.null(type)){ 190 | if(!type %in% c("terrestrial", "freshwater", "marine", 191 | "brackish", "host")){ 192 | stop("type should be one of terrestrial, freshwater, 193 | marine, brackish, host") 194 | } 195 | } 196 | #Parse url and extract table 197 | args <- orc(list(name = name, impacts = impacts, 198 | verified = verified, country = country, 199 | kindom = kindom, type = type)) 200 | cli <- crul::HttpClient$new(url = griis_base(), opts = list(...)) 201 | x <- cli$get("export_csv.php", query = args) 202 | warn_status(x) 203 | doc <- utils::read.table(x$url, header = TRUE, sep = ";", 204 | stringsAsFactors = FALSE) 205 | colnames(doc)[which(colnames(doc) == "Evidence.of.Impacts..Y.N.")] <- 206 | "Evidence.of.Impacts" 207 | colnames(doc)[which(colnames(doc) == "Verification..Y.N.")] <- "Verified" 208 | return(doc[,-which(colnames(doc) == "X")]) 209 | } 210 | 211 | griis_base <- function() "http://www.griis.org" 212 | 213 | -------------------------------------------------------------------------------- /R/is_native.R: -------------------------------------------------------------------------------- 1 | #' Check if a species is native somewhere 2 | #' 3 | #' @export 4 | #' 5 | #' @param sp character; a vector of length one with a single scientific species 6 | #' names in the form of \code{c("Genus species")}. 7 | #' @param region character; a vector of length one with a single region. Only "europe" 8 | #' and "america" implemented "europe" checks Flora Europaea and only contain plants. 9 | #' "america" checks ITIS and contain both plant and animals. 10 | #' @param where character; a vector of length one with a single place. For America has to 11 | #' match one of those: "Continental US", "Alaska", "Canada", "Caribbean Territories", 12 | #' "Central Pacific Territories", "Hawaii", "Mexico". For Europe has to match one of 13 | #' those: "Albania", "Austria", "Azores", "Belgium", "Islas_Baleares", "Britain", 14 | #' "Bulgaria", "Corse", "Kriti", "Czechoslovakia", "Denmark", "Faroer", "Finland", 15 | #' "France", "Germany", "Greece", "Ireland", "Switzerland", "Netherlands", "Spain", 16 | #' "Hungary", "Iceland", "Italy", "Jugoslavia", "Portugal", "Norway", "Poland", "Romania", 17 | #' "USSR", "Sardegna", "Svalbard", "Sicilia", "Sweden", "Turkey", "USSR_Northern_Division", 18 | #' "USSR_Baltic_Division", "USSR_Central_Division", "USSR_South_western", "USSR_Krym", 19 | #' "USSRSouth_eastern_Division" 20 | #' @param ... Curl options passed on to \code{\link[crul]{HttpClient}} 21 | #' @return A data.frame, with species name and result of origin check 22 | #' 23 | #' @description This function check the status (native or exotic) of a species in a 24 | #' given place 25 | #' 26 | #' For that end, calls \code{\link[taxize]{itis_native}} and \code{\link{flora_europaea}}. 27 | #' See help documentation of those functions for details. 28 | #' 29 | #' So many more things can be done, like checking species first with \pkg{taxize}, adding 30 | #' more native lists to check... 31 | #' 32 | #' @author Ignasi Bartomeus \email{nacho.bartomeus@@gmail.com} 33 | #' @examples \dontrun{ 34 | #' sp <- c("Lavandula stoechas", "Carpobrotus edulis", "Rhododendron ponticum", 35 | #' "Alkanna lutea", "Anchusa arvensis") 36 | #' is_native(sp[1], where = "Islas_Baleares", region = "europe") 37 | #' lapply(sp, is_native, where = "Continental US", region = "america") 38 | #' lapply(sp, is_native, where = "Islas_Baleares", region = "europe") 39 | #' 40 | #' # combine output for many taxa 41 | #' res <- lapply(sp, is_native, where = "Continental US", region = "america") 42 | #' do.call(rbind, res) 43 | #' } 44 | is_native <- function(sp, where, region = c("america", "europe"), ...) { 45 | if (!region %in% c("america", "europe")) { 46 | stop("region must be one of america or europe", call. = FALSE) 47 | } 48 | if (length(sp) > 1) { 49 | stop("sp should be a single species", call. = FALSE) 50 | } 51 | if (region == "america") { 52 | if (!where %in% c("Continental US", "Alaska", "Canada", 53 | "Caribbean Territories", "Central Pacific Territories", 54 | "Hawaii", "Mexico")) { 55 | stop("where must be one America region, see help for accepted names", call. = FALSE) 56 | } 57 | tsn_ <- taxize::get_tsn(sp, ...)[1] 58 | if (is.na(tsn_)) { 59 | Out <- "species not in itis" 60 | } else { 61 | origin <- taxize::itis_native(tsn = tsn_, ...) 62 | if (all(is.na(origin$origin))) { 63 | Out <- "species with no available origin in itis" 64 | } else { 65 | Out <- origin[which(origin$jurisdictionvalue == where), "origin"][[1]] 66 | if (length(Out) == 0) Out <- NA_character_ 67 | } 68 | } 69 | } 70 | if (region == "europe") { 71 | if (!where %in% c("Albania", "Austria", "Azores", "Belgium", "Islas_Baleares", 72 | "Britain", "Bulgaria", "Corse", "Kriti", 73 | "Czechoslovakia", "Denmark", "Faroer", 74 | "Finland", "France", "Germany", "Greece", 75 | "Ireland", "Switzerland", "Netherlands", "Spain", 76 | "Hungary", "Iceland", "Italy", "Jugoslavia", 77 | "Portugal", "Norway", "Poland", "Romania", 78 | "USSR", "Sardegna", "Svalbard", "Sicilia", 79 | "Sweden", "Turkey", "USSR_Northern_Division", 80 | "USSR_Baltic_Division", "USSR_Central_Division", 81 | "USSR_South_western", "USSR_Krym", 82 | "USSRSouth_eastern_Division")) { 83 | stop("where must be one eu country, see help for accepted names", call. = FALSE) 84 | } 85 | origin <- flora_europaea(sp) 86 | if (length(origin) < 5) { 87 | Out <- "Species not in flora europaea" 88 | } else { 89 | Out <- "Species not present in your selected region" 90 | if (where %in% origin$native) { 91 | Out <- "Native" 92 | } 93 | if (where %in% origin$exotic) { 94 | Out <- "Introduced" 95 | } 96 | if (where %in% c(origin$status_doubtful, origin$occurrence_doubtful, origin$extinct)) { 97 | Out <- "status or occurrence doubtful or species extinct" 98 | } 99 | } 100 | } 101 | data.frame(name = sp, origin = Out, stringsAsFactors = FALSE) 102 | } 103 | -------------------------------------------------------------------------------- /R/nsr.R: -------------------------------------------------------------------------------- 1 | #' Search the Native Species Resolver 2 | #' 3 | #' @export 4 | #' @param species (character) One or more species names. required. 5 | #' @param country (character) A country name. required. 6 | #' @param stateprovince (character) A state or province name 7 | #' @param countyparish (character) A county or parish name 8 | #' @param ... curl options passed on to [crul::HttpClient] 9 | #' @references http://bien.nceas.ucsb.edu/bien/tools/nsr/nsr-ws/ 10 | #' @details Currently, only one name is allowed per request. We loop internally 11 | #' over a list of length > 1, but this will still be slow due to only 1 12 | #' name per request. 13 | #' 14 | #' Note that this service can be quite slow. 15 | #' 16 | #' @section political names: 17 | #' 18 | #' - `nsr_countries`: is a vector of country names that we use to check 19 | #' your country names 20 | #' - `nsr_pol_divisions`: is a data.frame of country names and state/province 21 | #' names that we used to check your parameter inputs - these are for checklists 22 | #' that NSR has complete coverage for 23 | #' 24 | #' @examples \dontrun{ 25 | #' nsr("Pinus ponderosa", country = "United States") 26 | #' nsr(c("Pinus ponderosa", "Poa annua"), country = "United States") 27 | #' splist <- c("Pinus ponderosa", "Poa annua", "bromus tectorum", "Ailanthus altissima") 28 | #' nsr(splist, country = "United States") 29 | #' nsr(splist, country = "United States", stateprovince = "California") 30 | #' 31 | #' # curl options 32 | #' nsr("Pinus ponderosa", "United States", verbose = TRUE) 33 | #' } 34 | nsr <- function(species, country, stateprovince = NULL, countyparish = NULL, ...) { 35 | if (!country %in% nsr_countries) { 36 | warning("country ", country, " not in the NSR list of countries") 37 | } 38 | if (!is.null(stateprovince)) { 39 | if (!stateprovince %in% nsr_pol_divisions$state_province) { 40 | warning("state/province ", stateprovince, 41 | " not in the NSR list of state/provinces") 42 | } 43 | } 44 | tmp <- lapply(species, function(z) { 45 | args <- orc(list(format = 'json', species = z, country = country, 46 | stateprovince = stateprovince, countyparish = countyparish)) 47 | x <- nsr_GET(args, ...) 48 | orc(x) 49 | }) 50 | df <- data.table::rbindlist(tmp, fill = TRUE, use.names = TRUE) 51 | (df <- data.table::setDF(df)) 52 | } 53 | 54 | nsr_GET <- function(args, ...) { 55 | cli <- crul::HttpClient$new(url = nsr_base(), opts = list(...)) 56 | x <- cli$get("bien/apps/nsr/nsr_ws.php", query = args) 57 | x$raise_for_status() 58 | xx <- jsonlite::fromJSON(x$parse("UTF-8"), FALSE)$nsr_results 59 | if (length(xx) == 0) NULL else xx[[1]]$nsr_result 60 | } 61 | 62 | nsr_base <- function() "http://bien.nceas.ucsb.edu" 63 | -------------------------------------------------------------------------------- /R/originr-package.R: -------------------------------------------------------------------------------- 1 | #' @title originr 2 | #' @description Species Origin Data 3 | #' 4 | #' @importFrom crul HttpClient 5 | #' @importFrom jsonlite fromJSON 6 | #' @importFrom taxize get_uid classification get_tsn itis_native 7 | #' @importFrom xml2 read_xml xml_find_all xml_text 8 | #' @importFrom data.table rbindlist setDF 9 | #' @name originr-package 10 | #' @aliases originr 11 | #' @docType package 12 | #' @keywords package 13 | #' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} 14 | #' @author Ignasi Bartomeus \email{nacho.bartomeus@@gmail.com} 15 | #' 16 | #' @section Data sources in the package: 17 | #' \itemize{ 18 | #' \item Encyclopedia of Life (http://eol.org) 19 | #' \item Flora Europaea (http://rbg-web2.rbge.org.uk/FE/fe.html) 20 | #' \item Global Invasive Species Database (http://www.iucngisd.org/gisd) 21 | #' \item Native Species Resolver (http://bien.nceas.ucsb.edu/bien/tools/nsr/nsr-ws/) 22 | #' \item Integrated Taxonomic Information Service (http://www.itis.gov/) 23 | #' } 24 | NULL 25 | 26 | #' Vector of country names for use with NSR 27 | #' 28 | #' @format A vector of countries of length 251 29 | #' @name nsr_countries 30 | #' @docType data 31 | #' @keywords data 32 | NULL 33 | 34 | #' NSR political divisions 35 | #' 36 | #' @format A data frame with 73 rows and 2 variables: 37 | #' \describe{ 38 | #' \item{country}{Country name} 39 | #' \item{state_province}{State or province name} 40 | #' } 41 | #' 42 | #' @name nsr_pol_divisions 43 | #' @docType data 44 | #' @keywords data 45 | NULL 46 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | mssg <- function(v, ...) if (v) message(...) 2 | 3 | orc <- function(l) Filter(Negate(is.null), l) 4 | 5 | todf <- function(x) { 6 | (xyz <- data.table::setDF( 7 | data.table::rbindlist(x, use.names = TRUE, fill = TRUE) 8 | )) 9 | } 10 | 11 | `%||%` <- function (x, y) if (is.null(x) || length(x) == 0) y else x 12 | 13 | warn_status <- function(x) { 14 | if (!x$status_code < 300) { 15 | stat <- x$status_http() 16 | warning(sprintf("%s: %s - %s", 17 | x$status_code %||% "", stat$message %||% "", stat$explanation %||% "")) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /README-NOT.md: -------------------------------------------------------------------------------- 1 | originr 2 | ======== 3 | 4 | Species Origin Data 5 | 6 | 7 | [![Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.](https://www.repostatus.org/badges/latest/abandoned.svg)](https://www.repostatus.org/#abandoned) 8 | 9 | This package is no longer maintained. 10 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | originr 2 | ======== 3 | 4 | ```{r echo=FALSE} 5 | knitr::opts_chunk$set( 6 | warning = FALSE, 7 | message = FALSE, 8 | collapse = TRUE, 9 | comment = "#>" 10 | ) 11 | ``` 12 | 13 | [![cran checks](https://cranchecks.info/badges/worst/originr)](https://cranchecks.info/pkgs/originr) 14 | [![R-check](https://github.com/ropensci/originr/workflows/R-check/badge.svg)](https://github.com/ropensci/originr/actions?query=workflow%3AR-check) 15 | [![codecov.io](https://codecov.io/github/ropensci/originr/coverage.svg?branch=master)](https://codecov.io/github/ropensci/originr?branch=master) 16 | [![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/originr)](https://github.com/r-hub/cranlogs.app) 17 | [![cran version](http://www.r-pkg.org/badges/version/originr)](https://cran.r-project.org/package=originr) 18 | 19 | Species Origin Data 20 | 21 | Data sources: 22 | 23 | * Encyclopedia of Life http://eol.org 24 | * Flora Europaea http://rbg-web2.rbge.org.uk/FE/fe.html 25 | * Global Invasive Species Database http://www.iucngisd.org/gisd 26 | * Native Species Resolver http://bien.nceas.ucsb.edu/bien/tools/nsr/nsr-ws/ 27 | * Integrated Taxonomic Information Service http://www.itis.gov/ 28 | * Global Register of Introduced and Invasive Species http://www.griis.org/ 29 | 30 | ## Install 31 | 32 | Stable CRAN version 33 | 34 | ```{r eval=FALSE} 35 | install.packages("originr") 36 | ``` 37 | 38 | Development version 39 | 40 | ```{r eval=FALSE} 41 | remotes::install_github("ropensci/originr") 42 | ``` 43 | 44 | ```{r} 45 | library("originr") 46 | ``` 47 | 48 | ## EOL invasive species datasets 49 | 50 | Datasets included: 51 | 52 | * `gisd100` - 100 of the World's Worst Invasive Alien Species 53 | (Global Invasive Species Database) http://eol.org/collections/54500 54 | * `gisd` - Global Invasive Species Database 2013 http://eol.org/collections/54983 55 | * `isc` - Centre for Agriculture and Biosciences International Invasive Species 56 | Compendium (ISC) http://eol.org/collections/55180 57 | * `daisie` - Delivering Alien Invasive Species Inventories for Europe (DAISIE) Species 58 | List http://eol.org/collections/55179 59 | * `i3n` - IABIN Invasives Information Network (I3N) Species 60 | http://eol.org/collections/55176 61 | * `mineps` - Marine Invaders of the NE Pacific Species http://eol.org/collections/55331 62 | 63 | An example using `mineps` 64 | 65 | ```{r} 66 | eol(name='Ciona intestinalis', dataset='mineps') 67 | ``` 68 | 69 | ## Native Species Resolver 70 | 71 | ```{r} 72 | nsr("Pinus ponderosa", "United States") 73 | ``` 74 | 75 | ## Global Invasive Species Database 76 | 77 | ```{r} 78 | sp <- c("Carpobrotus edulis", "Rosmarinus officinalis") 79 | gisd(sp) 80 | ``` 81 | 82 | ## Flora Europaea 83 | 84 | ```{r} 85 | flora_europaea("Lavandula stoechas") 86 | ``` 87 | 88 | ## Meta 89 | 90 | * Please [report any issues or bugs](https://github.com/ropensci/originr/issues). 91 | * License: MIT 92 | * Get citation information for `originr` in R doing `citation(package = 'originr')` 93 | * Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms. 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # originr 2 | 3 | [![Project Status: Abandoned](https://www.repostatus.org/badges/latest/abandoned.svg)](https://www.repostatus.org/#abandoned) 4 | 5 | This repository has been archived. The former README is now in [README-NOT.md](README-NOT.md). 6 | -------------------------------------------------------------------------------- /codemeta.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": [ 3 | "http://purl.org/codemeta/2.0", 4 | "http://schema.org" 5 | ], 6 | "@type": "SoftwareSourceCode", 7 | "identifier": "originr", 8 | "description": "Get species origin data (whether species is native/invasive) from the\n following sources on the web: Encyclopedia of Life (), Flora\n 'Europaea' (), Global Invasive Species\n Database (), the Native Species Resolver\n (), Integrated Taxonomic\n Information Service (), and Global Register of\n Introduced and Invasive Species ().", 9 | "name": "originr: Fetch Species Origin Data from the Web", 10 | "codeRepository": "https://github.com/ropensci/originr", 11 | "issueTracker": "https://github.com/ropensci/originr/issues", 12 | "license": "https://spdx.org/licenses/MIT", 13 | "version": "0.4.0", 14 | "programmingLanguage": { 15 | "@type": "ComputerLanguage", 16 | "name": "R", 17 | "version": "4.0.1", 18 | "url": "https://r-project.org" 19 | }, 20 | "runtimePlatform": "R version 4.0.1 (2020-06-06)", 21 | "provider": { 22 | "@id": "https://cran.r-project.org", 23 | "@type": "Organization", 24 | "name": "Central R Archive Network (CRAN)", 25 | "url": "https://cran.r-project.org" 26 | }, 27 | "author": [ 28 | { 29 | "@type": "Person", 30 | "givenName": "Scott", 31 | "familyName": "Chamberlain", 32 | "email": "myrmecocystus@gmail.com", 33 | "@id": "https://orcid.org/0000-0003-1444-9135" 34 | }, 35 | { 36 | "@type": "Person", 37 | "givenName": "Ignasi", 38 | "familyName": "Bartomeus", 39 | "email": "nacho.bartomeus@gmail.com" 40 | } 41 | ], 42 | "maintainer": [ 43 | { 44 | "@type": "Person", 45 | "givenName": "Scott", 46 | "familyName": "Chamberlain", 47 | "email": "myrmecocystus@gmail.com", 48 | "@id": "https://orcid.org/0000-0003-1444-9135" 49 | } 50 | ], 51 | "softwareSuggestions": [ 52 | { 53 | "@type": "SoftwareApplication", 54 | "identifier": "testthat", 55 | "name": "testthat", 56 | "provider": { 57 | "@id": "https://cran.r-project.org", 58 | "@type": "Organization", 59 | "name": "Comprehensive R Archive Network (CRAN)", 60 | "url": "https://cran.r-project.org" 61 | }, 62 | "sameAs": "https://CRAN.R-project.org/package=testthat" 63 | }, 64 | { 65 | "@type": "SoftwareApplication", 66 | "identifier": "vcr", 67 | "name": "vcr", 68 | "provider": { 69 | "@id": "https://cran.r-project.org", 70 | "@type": "Organization", 71 | "name": "Comprehensive R Archive Network (CRAN)", 72 | "url": "https://cran.r-project.org" 73 | }, 74 | "sameAs": "https://CRAN.R-project.org/package=vcr" 75 | } 76 | ], 77 | "softwareRequirements": [ 78 | { 79 | "@type": "SoftwareApplication", 80 | "identifier": "crul", 81 | "name": "crul", 82 | "provider": { 83 | "@id": "https://cran.r-project.org", 84 | "@type": "Organization", 85 | "name": "Comprehensive R Archive Network (CRAN)", 86 | "url": "https://cran.r-project.org" 87 | }, 88 | "sameAs": "https://CRAN.R-project.org/package=crul" 89 | }, 90 | { 91 | "@type": "SoftwareApplication", 92 | "identifier": "jsonlite", 93 | "name": "jsonlite", 94 | "provider": { 95 | "@id": "https://cran.r-project.org", 96 | "@type": "Organization", 97 | "name": "Comprehensive R Archive Network (CRAN)", 98 | "url": "https://cran.r-project.org" 99 | }, 100 | "sameAs": "https://CRAN.R-project.org/package=jsonlite" 101 | }, 102 | { 103 | "@type": "SoftwareApplication", 104 | "identifier": "data.table", 105 | "name": "data.table", 106 | "provider": { 107 | "@id": "https://cran.r-project.org", 108 | "@type": "Organization", 109 | "name": "Comprehensive R Archive Network (CRAN)", 110 | "url": "https://cran.r-project.org" 111 | }, 112 | "sameAs": "https://CRAN.R-project.org/package=data.table" 113 | }, 114 | { 115 | "@type": "SoftwareApplication", 116 | "identifier": "xml2", 117 | "name": "xml2", 118 | "provider": { 119 | "@id": "https://cran.r-project.org", 120 | "@type": "Organization", 121 | "name": "Comprehensive R Archive Network (CRAN)", 122 | "url": "https://cran.r-project.org" 123 | }, 124 | "sameAs": "https://CRAN.R-project.org/package=xml2" 125 | }, 126 | { 127 | "@type": "SoftwareApplication", 128 | "identifier": "taxize", 129 | "name": "taxize", 130 | "version": ">= 0.9.0", 131 | "provider": { 132 | "@id": "https://cran.r-project.org", 133 | "@type": "Organization", 134 | "name": "Comprehensive R Archive Network (CRAN)", 135 | "url": "https://cran.r-project.org" 136 | }, 137 | "sameAs": "https://CRAN.R-project.org/package=taxize" 138 | } 139 | ], 140 | "contIntegration": "https://travis-ci.org/ropensci/originr", 141 | "releaseNotes": "https://github.com/ropensci/originr/blob/master/NEWS.md", 142 | "readme": "https://github.com/ropensci/originr/blob/master/README.md", 143 | "fileSize": "30.353KB", 144 | "applicationCategory": "Biology", 145 | "isPartOf": "https://ropensci.org", 146 | "keywords": ["species", "native", "invasive", "origin", "web", "API", "eol", "gisd", "nsr", "itis", "griis", "rstats", "invasive-species", "flora-europaea", "r", "r-package"], 147 | "relatedLink": "https://docs.ropensci.org/originr", 148 | "contributor": {}, 149 | "copyrightHolder": {}, 150 | "funder": {} 151 | } 152 | -------------------------------------------------------------------------------- /data/nsr_countries.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/originr/f4f84974ef890cbe6aa3c5a095362a4d97f67df7/data/nsr_countries.RData -------------------------------------------------------------------------------- /data/nsr_pol_divisions.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci-archive/originr/f4f84974ef890cbe6aa3c5a095362a4d97f67df7/data/nsr_pol_divisions.RData -------------------------------------------------------------------------------- /man/eol.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eol.R 3 | \name{eol} 4 | \alias{eol} 5 | \alias{eol_invasive_data} 6 | \title{Search for presence of taxonomic names in EOL invasive species databases.} 7 | \usage{ 8 | eol( 9 | name, 10 | dataset = "all", 11 | searchby = grep, 12 | page = NULL, 13 | per_page = 500, 14 | key = NULL, 15 | messages = TRUE, 16 | count = FALSE, 17 | ... 18 | ) 19 | 20 | eol_invasive_data(...) 21 | } 22 | \arguments{ 23 | \item{name}{A taxonomic name, or a vector of names.} 24 | 25 | \item{dataset}{One of all, gisd100, gisd, isc, daisie, i3n, or mineps. 26 | See the Details for what each dataset ID.} 27 | 28 | \item{searchby}{One of 'grep' (exact match) or 'agrep' (fuzzy match)} 29 | 30 | \item{page}{A maximum of 30 results are returned per page. This parameter 31 | allows you to fetch more pages of results if there are more than 30 matches 32 | (Default: 1)} 33 | 34 | \item{per_page}{Results to get per page. Default: 500} 35 | 36 | \item{key}{Your EOL API key; loads from .Rprofile.} 37 | 38 | \item{messages}{(logical) If \code{TRUE} the actual taxon queried is printed 39 | on the console.} 40 | 41 | \item{count}{(logical) If TRUE, give back a count of number of taxa listed 42 | as invasive, if \code{FALSE} (default), the normal output is given.} 43 | 44 | \item{...}{curl options passed on to \code{\link[crul]{HttpClient}}} 45 | } 46 | \value{ 47 | A list of data.frame's/strings with results, with each element 48 | named by the input elements to the name parameter. 49 | } 50 | \description{ 51 | See Details for important information. 52 | } 53 | \details{ 54 | \code{eol_invasive_data()} gives you the entire data.frame from 55 | the "dataset=all", while \code{eol()} let's you search on a vector of names 56 | against any of the datasets 57 | 58 | IMPORTANT: note that setting \code{dataset="all"} will give you surprising results. 59 | EOL does not include informaiton on which of the invasive datasets (i.e., gisd100, 60 | gisd, isc, daisie, i3n, or mineps) the taxon is found in, and sometimes e.g., if 61 | taxon X is in GISD, you might not find it in "all", weird. I don't know 62 | why that's happening, but it shouldn't happen. 63 | 64 | IMPORTANT: When you get a returned NaN for a taxon, that means it's not on 65 | the invasive list in question. If the taxon is found, a taxon identifier 66 | is returned. 67 | 68 | Beware that some datasets are quite large, and may take 30 sec to a minute to 69 | pull down all data before we can search for your species. Note there is no 70 | parameter in this API method for searching by taxon name. 71 | 72 | \code{eol()} is vectorized, so you can pass a single name or a vector 73 | of names. 74 | 75 | It's possible to return JSON or XML with the EOL API. However, this function 76 | only returns JSON. 77 | 78 | Options for the dataset parameter are 79 | \itemize{ 80 | \item all - All datasets 81 | \item gisd100 - 100 of the World's Worst Invasive Alien Species 82 | (Global Invasive Species Database) https://eol.org/resources/477 83 | \item gisd - Global Invasive Species Database 2013 84 | http://eol.org/collections/54983 85 | \item isc - Centre for Agriculture and Biosciences International Invasive 86 | Species Compendium (ISC) http://eol.org/collections/55180 87 | \item daisie - Delivering Alien Invasive Species Inventories for Europe 88 | (DAISIE) Species List http://eol.org/collections/55179 89 | \item i3n - IABIN Invasives Information Network (I3N) Species 90 | http://eol.org/collections/55176 91 | \item mineps - Marine Invaders of the NE Pacific 92 | Species http://eol.org/collections/55331 93 | } 94 | 95 | Datasets are not updated that often. Here's last updated dates for some of 96 | the datasets as of 2014-08-25 97 | \itemize{ 98 | \item gisd100 updated 6 mos ago 99 | \item gisd updated 1 yr ago 100 | \item isc updated 1 yr ago 101 | \item daisie updated 1 yr ago 102 | \item i3n updated 1 yr ago 103 | \item mineps updated 1 yr ago 104 | } 105 | } 106 | \examples{ 107 | \dontrun{ 108 | eol(name='Brassica oleracea', dataset='gisd') 109 | eol(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata', 110 | 'Pinus concolor'), dataset='gisd') 111 | eol(name='Sargassum', dataset='gisd') 112 | eol(name='Ciona intestinalis', dataset='mineps') 113 | eol(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata', 114 | 'Pinus concolor'), dataset='i3n') 115 | eol(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'), 116 | dataset='daisie') 117 | eol(name=c('Branta canadensis','Gallus gallus','Myiopsitta monachus'), 118 | dataset='isc') 119 | 120 | # Count 121 | eol(name=c('Lymantria dispar','Cygnus olor','Hydrilla verticillata', 122 | 'Pinus concolor'), dataset='gisd', count = TRUE) 123 | 124 | # curl options 125 | eol(name='Sargassum', dataset='gisd', verbose = TRUE) 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /man/flora_europaea.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/flora_europaea.R 3 | \name{flora_europaea} 4 | \alias{flora_europaea} 5 | \title{Check species status (native/exotic) in Flora Europaea} 6 | \usage{ 7 | flora_europaea(sp, messages = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{sp}{character; a vector of length one with a single scientific 11 | species names in the form of \code{c("Genus species")}.} 12 | 13 | \item{messages}{logical; If \code{TRUE} (default), informative messages 14 | printed} 15 | 16 | \item{...}{curl options passed on to \code{\link[crul]{HttpClient}}} 17 | } 18 | \value{ 19 | A list of vectors containing the countries where the species is 20 | native, exotic, ... 21 | } 22 | \description{ 23 | This function check the status (native or exotic) of a species 24 | in each of the eu countries. 25 | 26 | For that end, it checks Flora Europaea (http://rbg-web2.rbge.org.uk/FE/fe.html) 27 | and scrapes the data from there. 28 | 29 | Note that the webpage contains more information. 30 | 31 | As expected, the function is as good as the database is. I think for 32 | native species is robust but new exotic species are not added as to my 33 | knowledge the database is not updated anymore. The database is not able to 34 | recognize species synonyms. 35 | 36 | See \url{http://rbg-web2.rbge.org.uk/FE/data/countries} for explanation 37 | of the database codes. 38 | } 39 | \examples{ 40 | \dontrun{ 41 | sp <- c("Lavandula stoechas", "Carpobrotus edulis", "Rhododendron ponticum", 42 | "Alkanna lutea", "Anchusa arvensis") 43 | flora_europaea(sp[1]) 44 | sapply(sp, flora_europaea, simplify = FALSE) 45 | 46 | flora_europaea('Calendula officinalis') 47 | } 48 | 49 | } 50 | \author{ 51 | Ignasi Bartomeus \email{nacho.bartomeus@gmail.com} 52 | } 53 | -------------------------------------------------------------------------------- /man/gisd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gisd.R 3 | \name{gisd} 4 | \alias{gisd} 5 | \title{Check invasive species status for a set of species from GISD database} 6 | \usage{ 7 | gisd(x, simplify = FALSE, messages = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{character; a vector of scientific species names in the form of 11 | c("Genus species").} 12 | 13 | \item{simplify}{logical; returns a data.frame with the species name and the 14 | values "Invasive", "Not in GISD". I recomend to check first the not 15 | simplified version (default), which contains raw information about the 16 | level of invasiveness.} 17 | 18 | \item{messages}{logical; If \code{TRUE} (default), informative messages 19 | printed.} 20 | 21 | \item{...}{curl options passed on to \code{\link[crul]{HttpClient}}} 22 | } 23 | \value{ 24 | A list with species names, native range countries, and invasive 25 | range countries 26 | } 27 | \description{ 28 | This function check which species (both plants and animals) are 29 | considered "invaders" somewhere in the world. 30 | 31 | For that end, it checks GISD (http://www.iucngisd.org/gisd) and 32 | returns a value, either "Not in GISD" or the brief description presented in 33 | GISD. 34 | 35 | Note that the webpage contains more information. Also note that the function 36 | won't tell you if it's exotic in your area, a lot of exotic species are not 37 | considered invaders (yet). 38 | 39 | As expected, the function is as good as the database is, which I find quite 40 | reliable and well maintained. 41 | The database is also able to recognize a lot (but not all) of the species 42 | synonyms. 43 | 44 | Note that \code{\link{eol}} with source of gisd or gisd100 may end up with 45 | different results as this function goes directly to the GISD website, whereas 46 | EOL only updates their GISD data occassionally. See notes in \code{\link{eol}}. 47 | } 48 | \examples{ 49 | \dontrun{ 50 | sp <- c("Carpobrotus edulis", "Rosmarinus officinalis") 51 | ## first species is invasive, second one is not. 52 | gisd(sp) 53 | gisd(sp, simplify = TRUE) 54 | 55 | sp <- c("Carpobrotus edulis", "Rosmarinus officinalis", "Acacia mangium", 56 | "Archontophoenix cunninghamiana", "Antigonon leptopus") 57 | gisd(sp) 58 | gisd(sp, simplify = TRUE) 59 | } 60 | } 61 | \author{ 62 | Ignasi Bartomeus \email{nacho.bartomeus@gmail.com} 63 | } 64 | -------------------------------------------------------------------------------- /man/griis.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/griis.R 3 | \name{griis} 4 | \alias{griis} 5 | \title{Check invasive species status for a species from GRIIS database} 6 | \usage{ 7 | griis( 8 | name = NULL, 9 | impacts = NULL, 10 | verified = NULL, 11 | country = NULL, 12 | kindom = NULL, 13 | type = NULL, 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{name}{character; a string with the scientific species name in the 19 | form of "Genus species". Default is NULL: return all records.} 20 | 21 | \item{impacts}{character; "Yes" for returning only records with impacts. 22 | Default to NULL: return all records.} 23 | 24 | \item{verified}{character; "Yes" for returning only verified records. 25 | Default to NULL: return all records.} 26 | 27 | \item{country}{character containing a valid name of a country for which to 28 | filter the results. Default to NULL: return all records.} 29 | 30 | \item{kindom}{character containing a valid name of a kindom (plantae, 31 | animalia, fungi, protozoa, chromista, others, ) for which to filter the 32 | results. Default to NULL: return all records.} 33 | 34 | \item{type}{character containing a valid name of a environment type 35 | (terrestrial, freshwater, marine, brackish, host) for which to filter 36 | the results. Default to NULL: return all records.} 37 | 38 | \item{...}{curl options passed on to \code{\link[crul]{HttpClient}}} 39 | } 40 | \value{ 41 | A data.frame with species names, country where recorded, 42 | origin and source among other fields. 43 | } 44 | \description{ 45 | This retrieves information from GRIIS (http://www.griis.org/) 46 | and returns all the queried records. As other functions in this package, the 47 | function is as good as the database is. 48 | } 49 | \note{ 50 | It seems as 'name' overrides 'kindom', which means records from a 51 | a plant species will be returned even if kindom is set to animalia. 52 | } 53 | \examples{ 54 | \dontrun{ 55 | griis(name = "Carpobrotus edulis") 56 | griis(name = "Carpobrotus edulis", country = "Portugal") 57 | } 58 | 59 | } 60 | \author{ 61 | Ignasi Bartomeus \email{nacho.bartomeus@gmail.com} 62 | } 63 | -------------------------------------------------------------------------------- /man/is_native.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/is_native.R 3 | \name{is_native} 4 | \alias{is_native} 5 | \title{Check if a species is native somewhere} 6 | \usage{ 7 | is_native(sp, where, region = c("america", "europe"), ...) 8 | } 9 | \arguments{ 10 | \item{sp}{character; a vector of length one with a single scientific species 11 | names in the form of \code{c("Genus species")}.} 12 | 13 | \item{where}{character; a vector of length one with a single place. For America has to 14 | match one of those: "Continental US", "Alaska", "Canada", "Caribbean Territories", 15 | "Central Pacific Territories", "Hawaii", "Mexico". For Europe has to match one of 16 | those: "Albania", "Austria", "Azores", "Belgium", "Islas_Baleares", "Britain", 17 | "Bulgaria", "Corse", "Kriti", "Czechoslovakia", "Denmark", "Faroer", "Finland", 18 | "France", "Germany", "Greece", "Ireland", "Switzerland", "Netherlands", "Spain", 19 | "Hungary", "Iceland", "Italy", "Jugoslavia", "Portugal", "Norway", "Poland", "Romania", 20 | "USSR", "Sardegna", "Svalbard", "Sicilia", "Sweden", "Turkey", "USSR_Northern_Division", 21 | "USSR_Baltic_Division", "USSR_Central_Division", "USSR_South_western", "USSR_Krym", 22 | "USSRSouth_eastern_Division"} 23 | 24 | \item{region}{character; a vector of length one with a single region. Only "europe" 25 | and "america" implemented "europe" checks Flora Europaea and only contain plants. 26 | "america" checks ITIS and contain both plant and animals.} 27 | 28 | \item{...}{Curl options passed on to \code{\link[crul]{HttpClient}}} 29 | } 30 | \value{ 31 | A data.frame, with species name and result of origin check 32 | } 33 | \description{ 34 | This function check the status (native or exotic) of a species in a 35 | given place 36 | 37 | For that end, calls \code{\link[taxize]{itis_native}} and \code{\link{flora_europaea}}. 38 | See help documentation of those functions for details. 39 | 40 | So many more things can be done, like checking species first with \pkg{taxize}, adding 41 | more native lists to check... 42 | } 43 | \examples{ 44 | \dontrun{ 45 | sp <- c("Lavandula stoechas", "Carpobrotus edulis", "Rhododendron ponticum", 46 | "Alkanna lutea", "Anchusa arvensis") 47 | is_native(sp[1], where = "Islas_Baleares", region = "europe") 48 | lapply(sp, is_native, where = "Continental US", region = "america") 49 | lapply(sp, is_native, where = "Islas_Baleares", region = "europe") 50 | 51 | # combine output for many taxa 52 | res <- lapply(sp, is_native, where = "Continental US", region = "america") 53 | do.call(rbind, res) 54 | } 55 | } 56 | \author{ 57 | Ignasi Bartomeus \email{nacho.bartomeus@gmail.com} 58 | } 59 | -------------------------------------------------------------------------------- /man/nsr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nsr.R 3 | \name{nsr} 4 | \alias{nsr} 5 | \title{Search the Native Species Resolver} 6 | \usage{ 7 | nsr(species, country, stateprovince = NULL, countyparish = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{species}{(character) One or more species names. required.} 11 | 12 | \item{country}{(character) A country name. required.} 13 | 14 | \item{stateprovince}{(character) A state or province name} 15 | 16 | \item{countyparish}{(character) A county or parish name} 17 | 18 | \item{...}{curl options passed on to \link[crul:HttpClient]{crul::HttpClient}} 19 | } 20 | \description{ 21 | Search the Native Species Resolver 22 | } 23 | \details{ 24 | Currently, only one name is allowed per request. We loop internally 25 | over a list of length > 1, but this will still be slow due to only 1 26 | name per request. 27 | 28 | Note that this service can be quite slow. 29 | } 30 | \section{political names}{ 31 | 32 | \itemize{ 33 | \item \code{nsr_countries}: is a vector of country names that we use to check 34 | your country names 35 | \item \code{nsr_pol_divisions}: is a data.frame of country names and state/province 36 | names that we used to check your parameter inputs - these are for checklists 37 | that NSR has complete coverage for 38 | } 39 | } 40 | 41 | \examples{ 42 | \dontrun{ 43 | nsr("Pinus ponderosa", country = "United States") 44 | nsr(c("Pinus ponderosa", "Poa annua"), country = "United States") 45 | splist <- c("Pinus ponderosa", "Poa annua", "bromus tectorum", "Ailanthus altissima") 46 | nsr(splist, country = "United States") 47 | nsr(splist, country = "United States", stateprovince = "California") 48 | 49 | # curl options 50 | nsr("Pinus ponderosa", "United States", verbose = TRUE) 51 | } 52 | } 53 | \references{ 54 | http://bien.nceas.ucsb.edu/bien/tools/nsr/nsr-ws/ 55 | } 56 | -------------------------------------------------------------------------------- /man/nsr_countries.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/originr-package.R 3 | \docType{data} 4 | \name{nsr_countries} 5 | \alias{nsr_countries} 6 | \title{Vector of country names for use with NSR} 7 | \format{ 8 | A vector of countries of length 251 9 | } 10 | \description{ 11 | Vector of country names for use with NSR 12 | } 13 | \keyword{data} 14 | -------------------------------------------------------------------------------- /man/nsr_pol_divisions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/originr-package.R 3 | \docType{data} 4 | \name{nsr_pol_divisions} 5 | \alias{nsr_pol_divisions} 6 | \title{NSR political divisions} 7 | \format{ 8 | A data frame with 73 rows and 2 variables: 9 | \describe{ 10 | \item{country}{Country name} 11 | \item{state_province}{State or province name} 12 | } 13 | } 14 | \description{ 15 | NSR political divisions 16 | } 17 | \keyword{data} 18 | -------------------------------------------------------------------------------- /man/originr-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/originr-package.R 3 | \docType{package} 4 | \name{originr-package} 5 | \alias{originr-package} 6 | \alias{originr} 7 | \title{originr} 8 | \description{ 9 | Species Origin Data 10 | } 11 | \section{Data sources in the package}{ 12 | 13 | \itemize{ 14 | \item Encyclopedia of Life (http://eol.org) 15 | \item Flora Europaea (http://rbg-web2.rbge.org.uk/FE/fe.html) 16 | \item Global Invasive Species Database (http://www.iucngisd.org/gisd) 17 | \item Native Species Resolver (http://bien.nceas.ucsb.edu/bien/tools/nsr/nsr-ws/) 18 | \item Integrated Taxonomic Information Service (http://www.itis.gov/) 19 | } 20 | } 21 | 22 | \author{ 23 | Scott Chamberlain \email{myrmecocystus@gmail.com} 24 | 25 | Ignasi Bartomeus \email{nacho.bartomeus@gmail.com} 26 | } 27 | \keyword{package} 28 | -------------------------------------------------------------------------------- /originr.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | StripTrailingWhitespace: Yes 16 | 17 | BuildType: Package 18 | PackageUseDevtools: Yes 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | PackageCheckArgs: --as-cran 21 | -------------------------------------------------------------------------------- /tests/fixtures/flora_europaea.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: http://rbg-web2.rbge.org.uk/cgi-bin/nph-readbtree.pl/feout?FAMILY_XREF=&GENUS_XREF=Carpobrotus&SPECIES_XREF=edulis&TAXON_NAME_XREF=&RANK= 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | status: HTTP/1.0 200 Script results follow 19 | server: nphreadbtree.pl/1.0 via CERN/3.0 20 | content-type: text/html 21 | body: 22 | encoding: UTF-8 23 | file: no 24 | string: "\r\n\r\nFlora Europaea Search Results\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n
\r\n\"Royal\r\n

\r\n

Flora 36 | Europaea Search Results

\r\nClick here 37 | for information on the format of the data in this page.
\r\n
\r\n\r\n\r\n\r\n\r\n\r\n
\r\npage 1 of 1 showing

Hits 40 | 1 to 4 of 4 matching edulis and Carpobrotus

\r\n 
\r\n\r\n\r\n\r\n\r\n

1

Carpobrotus 43 | edulis (L.) N.E.Br.
Family: Aizoaceae
Genus: Carpobrotus
Species: edulis
Rank: species
Reference: Gen. S. Afr. Fl. Pl. 45 | ed. 1 249 (1926)
Name status: Accepted
Synonym(s):
  • Mesembryanthemum 46 | edule L.

Distribution: 47 | [Al Az Be Bl Br Co Ga Gr Hb Hs It Lu Si]
Cultivated, and naturalized 48 | in S. & W. Europe, northwards to N. Wales

\r\n

\r\n


\r\n\r\n\r\n\r\n

2

Carpobrotus 51 | edulis (L.) N.E.Br. var. edulis
Family: Aizoaceae
Genus: 52 | Carpobrotus
Species: edulis
Rank: var.
Name status: External

\r\n

\r\n


\r\n\r\n\r\n\r\n

3

Carpobrotus edulis 56 | (L.) N.E.Br. var. chrysophthalmus C.D.Preston & P.D.Sell
Family: Aizoaceae
Genus: Carpobrotus
Species: edulis
Rank: 58 | var.
Name status: Accepted
Cultivated, and naturalized in 59 | S. & W. Europe, northwards to N. Wales

\r\n

\r\n


\r\n\r\n\r\n\r\n

4

Carpobrotus 62 | edulis (L.) N.E.Br. var. rubescens Druce
Family: Aizoaceae
Genus: Carpobrotus
Species: edulis
Rank: var.
Name status: 64 | Accepted
Synonym(s):
  • Carpobrotus acinaciformis 65 | auct. eur., non (L.) L.Bolus
  • Mesembryanthemum acinaciforme 66 | auct. eur., non L.

Cultivated, and naturalized in S. & 67 | W. Europe, northwards to N. Wales

\r\n

\r\n



\r\n\r\n\r\n\r\n\r\n\r\n
\r\nNo more hits

\r\n

\r\n
\r\n\r\n\r\n 70 | \r\n \r\n 71 | \r\n\r\n
\r\n New query | \r\n \r\n Return to the RBGE home page\r\n 72 |
\r\n

\r\n


\r\nRoyal Botanic Garden Edinburgh, 73 | Inverleith Row, Edinburgh, EH3 5LR, United Kingdom.
\r\nTel. +44 (0)131 74 | 552 7171 ~ Fax +44 (0)131 552 0382\r\n\r\n\r\n\r\n" 75 | recorded_at: 2020-06-03 21:06:58 GMT 76 | recorded_with: vcr/0.5.4, webmockr/0.6.2 77 | - request: 78 | method: get 79 | uri: http://rbg-web2.rbge.org.uk/cgi-bin/nph-readbtree.pl/feout?FAMILY_XREF=&GENUS_XREF=Rosmarinus&SPECIES_XREF=officinalis&TAXON_NAME_XREF=&RANK= 80 | body: 81 | encoding: '' 82 | string: '' 83 | headers: 84 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 85 | Accept-Encoding: gzip, deflate 86 | Accept: application/json, text/xml, application/xml, */* 87 | response: 88 | status: 89 | status_code: '200' 90 | message: OK 91 | explanation: Request fulfilled, document follows 92 | headers: 93 | status: HTTP/1.0 200 Script results follow 94 | server: nphreadbtree.pl/1.0 via CERN/3.0 95 | content-type: text/html 96 | body: 97 | encoding: UTF-8 98 | file: no 99 | string: "\r\n\r\nFlora Europaea Search Results\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n
\r\n\"Royal\r\n

\r\n

Flora 111 | Europaea Search Results

\r\nClick here 112 | for information on the format of the data in this page.
\r\n
\r\n\r\n\r\n\r\n\r\n\r\n
\r\npage 1 of 1 showing

Hits 115 | 1 to 1 of 1 matching officinalis and Rosmarinus

\r\n 
\r\n\r\n\r\n\r\n\r\n

1

Rosmarinus 118 | officinalis L.
Family: Labiatae
Genus: Rosmarinus
Species: 119 | officinalis
Rank: species
Reference: Sp. Pl. ed. 1 23 (1753)
Name status: Accepted
Synonym(s):
  • Rosmarinus laxiflorus 121 | Noë ex Lange

Distribution: 122 | Bl Co *Cr Ga Gr Hs It Ju Lu Sa Si [Al Az Bu He Rs(K)]

\r\n

\r\n



\r\n\r\n\r\n\r\n\r\n\r\n
\r\nNo more hits

\r\n

\r\n
\r\n\r\n\r\n 125 | \r\n \r\n 126 | \r\n\r\n
\r\n New query | \r\n \r\n Return to the RBGE home page\r\n 127 |
\r\n

\r\n


\r\nRoyal Botanic Garden Edinburgh, 128 | Inverleith Row, Edinburgh, EH3 5LR, United Kingdom.
\r\nTel. +44 (0)131 129 | 552 7171 ~ Fax +44 (0)131 552 0382\r\n\r\n\r\n\r\n" 130 | recorded_at: 2020-06-03 21:06:58 GMT 131 | recorded_with: vcr/0.5.4, webmockr/0.6.2 132 | -------------------------------------------------------------------------------- /tests/fixtures/flora_europaea_fail.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: http://rbg-web2.rbge.org.uk/cgi-bin/nph-readbtree.pl/feout?FAMILY_XREF=&GENUS_XREF=asdfadsf&SPECIES_XREF=NA&TAXON_NAME_XREF=&RANK= 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | status: HTTP/1.0 200 Script results follow 19 | server: nphreadbtree.pl/1.0 via CERN/3.0 20 | content-type: text/html 21 | body: 22 | encoding: UTF-8 23 | file: no 24 | string: "\r\n\r\nFlora Europaea Search Results\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n
\r\n\"Royal\r\n

\r\n

Flora 36 | Europaea Search Results

\r\nClick here 37 | for information on the format of the data in this page.
\r\n
\r\n

Hits matching NA and asdfadsf


No matches found

\r\n\r\n\r\n\r\n 40 | \r\n \r\n 41 | \r\n\r\n
\r\n New query | \r\n \r\n Return to the RBGE home page\r\n 42 |
\r\n

\r\n


\r\nRoyal Botanic Garden Edinburgh, 43 | Inverleith Row, Edinburgh, EH3 5LR, United Kingdom.
\r\nTel. +44 (0)131 44 | 552 7171 ~ Fax +44 (0)131 552 0382\r\n\r\n\r\n\r\n" 45 | recorded_at: 2020-06-03 21:06:59 GMT 46 | recorded_with: vcr/0.5.4, webmockr/0.6.2 47 | -------------------------------------------------------------------------------- /tests/fixtures/gisd.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: https://api.gbif.org/v1/species?datasetKey=b351a324-77c4-41c9-a909-f30f77268bc4&name=Carpobrotus%20edulis 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | status: HTTP/1.1 200 OK 19 | date: Wed, 03 Jun 2020 21:12:18 GMT 20 | content-type: application/json 21 | access-control-allow-origin: '*' 22 | access-control-allow-methods: HEAD, GET, POST, DELETE, PUT, OPTIONS 23 | server: Jetty(9.3.z-SNAPSHOT) 24 | cache-control: public, max-age=3601 25 | x-varnish: '101090163' 26 | age: '0' 27 | via: 1.1 varnish (Varnish/5.2) 28 | accept-ranges: bytes 29 | transfer-encoding: chunked 30 | connection: keep-alive 31 | body: 32 | encoding: UTF-8 33 | file: no 34 | string: '{"offset":0,"limit":20,"endOfRecords":true,"results":[{"key":100221500,"nubKey":3084842,"nameKey":2052609,"taxonID":"1010","kingdom":"Plantae","phylum":"Magnoliophyta","kingdomKey":132916967,"phylumKey":132916985,"datasetKey":"b351a324-77c4-41c9-a909-f30f77268bc4","parentKey":132916985,"parent":"Magnoliophyta","scientificName":"Carpobrotus 35 | edulis","canonicalName":"Carpobrotus edulis","authorship":"","nameType":"SCIENTIFIC","origin":"SOURCE","taxonomicStatus":"ACCEPTED","nomenclaturalStatus":[],"numDescendants":0,"references":"http://www.invasivespecies.net/database/species/ecology.asp?si=1010&fr=1&sts=&lang=EN","lastCrawled":"2019-09-07T22:18:50.867+0000","lastInterpreted":"2017-08-25T14:34:29.147+0000","issues":[],"synonym":false}]}' 36 | recorded_at: 2020-06-03 21:12:20 GMT 37 | recorded_with: vcr/0.5.4, webmockr/0.6.2 38 | - request: 39 | method: get 40 | uri: https://api.gbif.org/v1/species?datasetKey=b351a324-77c4-41c9-a909-f30f77268bc4&name=Rosmarinus%20officinalis 41 | body: 42 | encoding: '' 43 | string: '' 44 | headers: 45 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 46 | Accept-Encoding: gzip, deflate 47 | Accept: application/json, text/xml, application/xml, */* 48 | response: 49 | status: 50 | status_code: '200' 51 | message: OK 52 | explanation: Request fulfilled, document follows 53 | headers: 54 | status: HTTP/1.1 200 OK 55 | date: Wed, 03 Jun 2020 21:12:20 GMT 56 | content-type: application/json 57 | access-control-allow-origin: '*' 58 | access-control-allow-methods: HEAD, GET, POST, DELETE, PUT, OPTIONS 59 | server: Jetty(9.3.z-SNAPSHOT) 60 | cache-control: public, max-age=3601 61 | x-varnish: '112001635' 62 | age: '0' 63 | via: 1.1 varnish (Varnish/5.2) 64 | accept-ranges: bytes 65 | content-length: '56' 66 | connection: keep-alive 67 | body: 68 | encoding: UTF-8 69 | file: no 70 | string: '{"offset":0,"limit":20,"endOfRecords":true,"results":[]}' 71 | recorded_at: 2020-06-03 21:12:20 GMT 72 | recorded_with: vcr/0.5.4, webmockr/0.6.2 73 | -------------------------------------------------------------------------------- /tests/fixtures/gisd_not_found.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: https://api.gbif.org/v1/species?datasetKey=b351a324-77c4-41c9-a909-f30f77268bc4&name=asdfadsf 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | status: HTTP/1.1 200 OK 19 | date: Wed, 03 Jun 2020 21:12:20 GMT 20 | content-type: application/json 21 | access-control-allow-origin: '*' 22 | access-control-allow-methods: HEAD, GET, POST, DELETE, PUT, OPTIONS 23 | server: Jetty(9.3.z-SNAPSHOT) 24 | cache-control: public, max-age=3601 25 | x-varnish: '117080093' 26 | age: '0' 27 | via: 1.1 varnish (Varnish/5.2) 28 | accept-ranges: bytes 29 | content-length: '56' 30 | connection: keep-alive 31 | body: 32 | encoding: UTF-8 33 | file: no 34 | string: '{"offset":0,"limit":20,"endOfRecords":true,"results":[]}' 35 | recorded_at: 2020-06-03 21:12:20 GMT 36 | recorded_with: vcr/0.5.4, webmockr/0.6.2 37 | -------------------------------------------------------------------------------- /tests/fixtures/griis.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: http://www.griis.org/export_csv.php?name=Carpobrotus%20edulis 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | status: HTTP/1.1 200 OK 19 | date: Wed, 03 Jun 2020 21:10:38 GMT 20 | server: Apache 21 | content-disposition: attachment; filename=export_griis.csv 22 | content-length: '9050' 23 | x-powered-by: PleskLin 24 | cache-control: max-age=60, private, proxy-revalidate 25 | connection: close 26 | content-type: application/download 27 | body: 28 | encoding: UTF-8 29 | file: no 30 | string: "\"Species\";\"Authority\";\"Country\";\"Kingdom\";\"Environment/System\";\"Origin\";\"Evidence 31 | of Impacts (Y/N)\";\"Verification (Y/N)\";\"Date\";\"Source\";\r\n\"Carpobrotus 32 | edulis\";\"N.E. Br. (L.)\";\"Albania\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"CAB 33 | International (2014). CABI Invasive Species Compendium (ISC). \r\nBarina, 34 | Z., Rakaj, M., Somoygi, G., Eros-Honti, Z., Pifko, D (2014). The alien ?ora 35 | of Albania: history, current status and future trends. Weed Research. 54, 36 | 196-215. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. Br. (L.)\";\"Algeria\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"Zedam, 37 | A. (2013). Zedam, A. Pers.comm July 2013. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 38 | Br. (L.)\";\"Angola\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"Republic 39 | of Angola, Ministry of Environment (2009). Framework report on Angola's Biodiversity. 40 | \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. Br. (L.)\";\"Argentina\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"CAB 41 | International (2014). CABI Invasive Species Compendium (ISC). \r\nGhersa, 42 | Claudio M., de la Fuente, Elba, Suarez, Susana, Leon, Rolando J. C. (2002). 43 | Woody species invasion in the Rolling Pampa grasslands, Argentina. Agriculture 44 | Ecosystems & Environment. 88, 3: 271-278. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 45 | Br. (L.)\";\"Australia\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"Randall, 46 | R.P. (2007). The Introduced Flora of Australia and its Weed Status. \r\n\";\r\n\"Carpobrotus 47 | edulis\";\"N.E. Br. (L.)\";\"Belgium\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"''RINSE 48 | - Reducing the Impact of Non-Native Species in Europe'' (2015). ''RINSE - 49 | Reducing the Impact of Non-Native Species in Europe''. \r\n\";\r\n\"Carpobrotus 50 | edulis\";\"N.E. Br. (L.)\";\"Bermuda\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"Invasive 51 | Species Specialist Group (2015). Global Invasive Species Database. \r\n\";\r\n\"Carpobrotus 52 | edulis\";\"N.E. Br. (L.)\";\"Bolivia\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"CAB 53 | International (2014). CABI Invasive Species Compendium (ISC). \r\n\";\r\n\"Carpobrotus 54 | edulis\";\"N.E. Br. (L.)\";\"Cabo Verde\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"CAB 55 | International (2014). CABI Invasive Species Compendium (ISC). \r\n\";\r\n\"Carpobrotus 56 | edulis\";\"N.E. Br. (L.)\";\"Chile- Juan Fernandez Islands\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"Swenson, 57 | U., Stuessey, T. F., Baeza, M., Crawford, D. J. (1997). New and Historical 58 | Plant Introductions, and Potential Pests in the Juan Fernandez Islands, Chile 59 | (http://www.iucnredlist.org/details/57291/0)Pacific Science. 51, 3: 233-253. 60 | \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. Br. (L.)\";\"Croatia\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"Mitic, 61 | B. (Collaborators- I. Bor?i?, M. Milovi?, S. Bogdanovi?, I. Dujmovi?, P. Cigi?, 62 | I. Re?etnik, R. ?o?tari?, N. Vukovi?, D. Hru?evar, S. Jelaska & T. Nikoli?) 63 | (2013). Invasive Alien Plans in Croatia. International seminar ?Lists of IAS 64 | \ plants in the Balkans with an EPPO training course on the priorization 65 | process for IAS plants, Belgrade, July 08-11, 2013. \r\n\";\r\n\"Carpobrotus 66 | edulis\";\"N.E. Br. (L.)\";\"Cyprus\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"DAISIE 67 | (Delivering Alien Invasive Species Inventories for Europe) (2006). Delivering 68 | Alien Invasive Species Inventories for Europe. \r\nHand R., Hadjikyriakou 69 | G. N. & Christodoulou C. S. (ed.) (2011). Flora of Cyprus ? a dynamic checklist.. 70 | \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. Br. (L.)\";\"France\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"DAISIE 71 | (Delivering Alien Invasive Species Inventories for Europe) (2006). Delivering 72 | Alien Invasive Species Inventories for Europe. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 73 | Br. (L.)\";\"Greece\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"Arianoutsou, 74 | M., Bazos, I., Delipetrou, P., and Kokkoris, Y. (2010). The alien flora of 75 | Greece: taxonomy, life traits and habitat. Biological Invasions. 12, 3525?3549. 76 | \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. Br. (L.)\";\"Ireland\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"Reynolds, 77 | S. C.P. (2002). A catalogue of alien plants in Ireland. \r\nThe National Biodiversity 78 | Data Centre (2014). National Invasive Species Database. \r\n\";\r\n\"Carpobrotus 79 | edulis\";\"N.E. Br. (L.)\";\"Israel\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"Jean-Marc 80 | Dufour-Dror (2012). Alien Invasive Plants in Israel. \r\n\";\r\n\"Carpobrotus 81 | edulis\";\"N.E. Br. (L.)\";\"Malta\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"DAISIE 82 | (Delivering Alien Invasive Species Inventories for Europe) (2006). Delivering 83 | Alien Invasive Species Inventories for Europe. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 84 | Br. (L.)\";\"Mexico\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"No\";\"2017\";\"CONABIO 85 | (Comisin nacional para el conocimiento y uso de la biodiversidad) (2015). 86 | Draft Inventory of Alien and Invasive species. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 87 | Br. (L.)\";\"Montenegro\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"Ste?evi?, 88 | D. and Petrovi?, D. (2010). Preliminary list of plant invaders in Montenegro. 89 | Biologica Nyssana. 1, (1-2): 35-42. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 90 | Br. (L.)\";\"New Zealand\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"Howell, 91 | C. (2008). Consolidated list of environmental weeds in New Zealand. DOC Research 92 | and Development Series 292. \r\nHowell, C. and Terry, J. (2016). The creation 93 | of a New Zealand weed atlas. Science for Conservation Series. 328, 21. \r\n\";\r\n\"Carpobrotus 94 | edulis\";\"N.E. Br. (L.)\";\"Norway\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"Gederaas, 95 | L., Moen, T.L., Skjelseth, S. & Larsen, L.-K. (eds.). (2012). Alien species 96 | in Norway?with the Norwegian Black List 2012. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 97 | Br. (L.)\";\"Portugal\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"DAISIE 98 | (Delivering Alien Invasive Species Inventories for Europe) (2006). Delivering 99 | Alien Invasive Species Inventories for Europe. \r\nBorges, P.A.V., Abreu, 100 | C., Aguiar, A.M.F., Carvalho, P., Jardim, R., Melo, I., Oliveira, P., Srgio, 101 | C., Serrano, A.R.M. & Vieira, P. (eds.) (2008). A list of the terrestrial 102 | fungi, flora and fauna of Madeira and Selvagens archipelagos.. \r\nInvasoras 103 | (2014a). Invasive Plants in Portugal- 1. \r\nInvasoras (2014b). Invasive Plants 104 | in Portugal- 2. \r\nBrunel, S., Brundu, G., Fried, G. (2013). Eradication 105 | and control of invasive alien plants in the Mediterranean Basin: towards better 106 | coordination to enhance existing initiatives. Bulletin OEPP. 43, 2: 290-308. 107 | \r\nAlmeida, J. D. & H. Freitas, H. (2006). Flora extica de Portugal continental 108 | ? uma reviso. Bot. Complut.. 30, 117-130. \r\nMaltez-Mouro, Sara, Maestre, 109 | Fernando T., Freitas, Helena (2010). Weak effects of the exotic invasive Carpobrotus 110 | edulis on the structure and composition of Portuguese sand-dune communities. 111 | Biological Invasions. 12, 7: 2117-2130. \r\nMinistry of Environment - Portugal 112 | (1999). Decreto-Lei n. 565/99. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 113 | Br. (L.)\";\"Spain\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"''Base 114 | de Datos de Especies Introducidas en Canarias'' (2014). Gobierno de Canarias. 115 | \r\nNovoa, Ana, Gonzalez, Luis, Moravcova, Lenka, Pysek, Petr (2010). Effects 116 | of Soil Characteristics, Allelopathy and Frugivory on Establishment of the 117 | Invasive Plant Carpobrotus edulis and a Co-Occuring Native, Malcolmia littorea. 118 | PLoS One. 7, 12: e53166. \r\nBrunel, S., Brundu, G., Fried, G. (2013). Eradication 119 | and control of invasive alien plants in the Mediterranean Basin: towards better 120 | coordination to enhance existing initiatives. Bulletin OEPP. 43, 2: 290-308. 121 | \r\nTouza, Julia, Perez-Alonso, Alicia, Chas-Amil, Maria L., Dehnen-Schmutz, 122 | Katharina (2014). Explaining the rank order of invasive plants by stakeholder 123 | groups. Ecological Economics. 105, 330-341. \r\nGovernment of Spain (2013). 124 | Boletin Oficial Del Estado. No 85 Sbado 3 de agosto de 2013. \r\nSanz-Elorza, 125 | M., Dana, E.D. & Sobrino, E. (2004). Atlas de las plantas alctonas invasoras 126 | de Espaa. Direccin General para la Biodiversidad, Madrid, Spain.. 127 | \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. Br. (L.)\";\"Tunisia\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"Invasive 128 | Species Specialist Group (2015). Global Invasive Species Database. \r\nCAB 129 | International (2014). CABI Invasive Species Compendium (ISC). \r\n\";\r\n\"Carpobrotus 130 | edulis\";\"N.E. Br. (L.)\";\"Turkey\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"No\";\"2017\";\"DAISIE 131 | (Delivering Alien Invasive Species Inventories for Europe) (2006). Delivering 132 | Alien Invasive Species Inventories for Europe. \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. 133 | Br. (L.)\";\"United Kingdom of Great Britain and Northern Ireland\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"GB 134 | Non-native Species Secretariat (2016). GB Non-native Species Information Portal. 135 | \r\n\";\r\n\"Carpobrotus edulis\";\"N.E. Br. (L.)\";\"Uruguay\";\"Plantae\";\"terrestrial\";\"Alien\";\"Yes\";\"Yes\";\"2017\";\"Masciadri, 136 | S., Brugnoli, E. & Muniz, P. (2010). InBUy Database of Invasive and Alien 137 | Species (IAS) in Uruguay: a useful tool to confront this threat to biodiversity. 138 | Biota Neotrop. 10, 4: \r\n\";\r\n\"Carpobrotus edulis x virescens\";\"\";\"Australia\";\"Plantae\";\"terrestrial\";\"Alien\";\"No\";\"Yes\";\"2017\";\"Randall, 139 | R.P. (2007). The Introduced Flora of Australia and its Weed Status. \r\n\";\r\n" 140 | recorded_at: 2020-06-03 21:10:43 GMT 141 | recorded_with: vcr/0.5.4, webmockr/0.6.2 142 | -------------------------------------------------------------------------------- /tests/fixtures/is_native.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: https://www.itis.gov/ITISWebService/jsonservice/getITISTermsFromScientificName?srchKey=Carpobrotus%20edulis 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | connection: keep-alive 19 | content-length: '318' 20 | content-type: text/json;charset=ISO-8859-1 21 | date: Wed, 03 Jun 2020 21:04:24 GMT 22 | status: 'HTTP/1.1 200 ' 23 | strict-transport-security: 24 | - max-age=63072000; includeSubdomains; preload 25 | - max-age=63072000; includeSubdomains; preload 26 | x-application: itis_webservices 27 | x-node-name: not shown 28 | x-upstream-member: not shown 29 | body: 30 | encoding: UTF-8 31 | file: no 32 | string: | 33 | {"class":"gov.usgs.itis.itis_service.data.SvcItisTermList","itisTerms":[{"author":"(L.) N.E. Br.","class":"gov.usgs.itis.itis_service.data.SvcItisTerm","commonNames":["freeway iceplant","Hottentot-fig"],"nameUsage":"accepted","scientificName":"Carpobrotus edulis","tsn":"19934"}],"requestedName":"Carpobrotus edulis"} 34 | recorded_at: 2020-06-03 21:04:25 GMT 35 | recorded_with: vcr/0.5.4, webmockr/0.6.2 36 | - request: 37 | method: get 38 | uri: https://www.itis.gov/ITISWebService/jsonservice/getJurisdictionalOriginFromTSN?tsn=19934 39 | body: 40 | encoding: '' 41 | string: '' 42 | headers: 43 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 44 | Accept-Encoding: gzip, deflate 45 | Accept: application/json, text/xml, application/xml, */* 46 | response: 47 | status: 48 | status_code: '200' 49 | message: OK 50 | explanation: Request fulfilled, document follows 51 | headers: 52 | connection: keep-alive 53 | content-length: '275' 54 | content-type: text/json;charset=ISO-8859-1 55 | date: Wed, 03 Jun 2020 21:04:25 GMT 56 | status: 'HTTP/1.1 200 ' 57 | strict-transport-security: 58 | - max-age=63072000; includeSubdomains; preload 59 | - max-age=63072000; includeSubdomains; preload 60 | x-application: itis_webservices 61 | x-node-name: not shown 62 | x-upstream-member: not shown 63 | body: 64 | encoding: UTF-8 65 | file: no 66 | string: | 67 | {"class":"gov.usgs.itis.itis_service.data.SvcTaxonJurisdictionalOriginList","jurisdictionalOrigins":[{"class":"gov.usgs.itis.itis_service.data.SvcTaxonJurisdictionalOrigin","jurisdictionValue":"Continental US","origin":"Introduced","updateDate":"2000-03-15"}],"tsn":"19934"} 68 | recorded_at: 2020-06-03 21:04:25 GMT 69 | recorded_with: vcr/0.5.4, webmockr/0.6.2 70 | -------------------------------------------------------------------------------- /tests/fixtures/nsr.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: http://bien.nceas.ucsb.edu/bien/apps/nsr/nsr_ws.php?format=json&species=Pinus%20ponderosa&country=United%20States 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | status: HTTP/1.1 200 OK 19 | date: Wed, 03 Jun 2020 21:08:13 GMT 20 | server: Apache/2.4.29 (Ubuntu) 21 | content-length: '290' 22 | content-type: application/json 23 | body: 24 | encoding: UTF-8 25 | file: no 26 | string: '{"nsr_results":[{"nsr_result":{"family":"Pinaceae","genus":"Pinus","species":"Pinus 27 | ponderosa","country":"United States","state_province":"","county_parish":"","native_status":"N","native_status_reason":"Native 28 | to region","native_status_sources":"","isIntroduced":"0","isCultivated":"0"}}]}' 29 | recorded_at: 2020-06-03 21:08:13 GMT 30 | recorded_with: vcr/0.5.4, webmockr/0.6.2 31 | -------------------------------------------------------------------------------- /tests/fixtures/nsr_no_results.yml: -------------------------------------------------------------------------------- 1 | http_interactions: 2 | - request: 3 | method: get 4 | uri: http://bien.nceas.ucsb.edu/bien/apps/nsr/nsr_ws.php?format=json&species=adadfd&country=United%20States 5 | body: 6 | encoding: '' 7 | string: '' 8 | headers: 9 | User-Agent: libcurl/7.70.0 r-curl/4.3 crul/0.9.0 10 | Accept-Encoding: gzip, deflate 11 | Accept: application/json, text/xml, application/xml, */* 12 | response: 13 | status: 14 | status_code: '200' 15 | message: OK 16 | explanation: Request fulfilled, document follows 17 | headers: 18 | status: HTTP/1.1 200 OK 19 | date: Wed, 03 Jun 2020 21:09:39 GMT 20 | server: Apache/2.4.29 (Ubuntu) 21 | content-length: '293' 22 | content-type: application/json 23 | body: 24 | encoding: UTF-8 25 | file: no 26 | string: '{"nsr_results":[{"nsr_result":{"family":"","genus":"adadfd","species":"","country":"United 27 | States","state_province":"","county_parish":"","native_status":"A","native_status_reason":"Absent 28 | from all checklists for region","native_status_sources":"usda","isIntroduced":"1","isCultivated":"0"}}]}' 29 | recorded_at: 2020-06-03 21:09:40 GMT 30 | recorded_with: vcr/0.5.4, webmockr/0.6.2 31 | -------------------------------------------------------------------------------- /tests/test-all.R: -------------------------------------------------------------------------------- 1 | library("testthat") 2 | test_check("originr") 3 | -------------------------------------------------------------------------------- /tests/testthat/helper-originr.R: -------------------------------------------------------------------------------- 1 | library("vcr") 2 | invisible(vcr::vcr_configure( 3 | dir = "../fixtures" 4 | )) 5 | vcr::check_cassette_names() 6 | -------------------------------------------------------------------------------- /tests/testthat/test-eol.R: -------------------------------------------------------------------------------- 1 | context("eol functions") 2 | 3 | # test_that("eol works", { 4 | # skip_on_cran() 5 | 6 | # aa <- eol(name = 'Brassica oleracea', dataset = 'gisd', messages = FALSE) 7 | # bb <- eol(name = 'Ciona intestinalis', dataset = 'mineps', messages = FALSE) 8 | # cc <- eol(name = c('Lymantria dispar','Cygnus olor'), dataset = 'i3n', messages = FALSE) 9 | 10 | # expect_is(aa, "data.frame") 11 | # expect_equal(aa$searched_name, 'Brassica oleracea') 12 | # expect_is(aa$searched_name, 'character') 13 | # expect_equal(aa$db, "gisd") 14 | 15 | # expect_is(bb, "data.frame") 16 | # expect_equal(bb$searched_name, 'Ciona intestinalis') 17 | # expect_is(bb$searched_name, 'character') 18 | # expect_equal(bb$db, "mineps") 19 | 20 | # expect_is(cc, "data.frame") 21 | # expect_equal(cc$searched_name, c('Lymantria dispar','Cygnus olor')) 22 | # expect_is(cc$searched_name, 'character') 23 | # expect_equal(cc$db[1], "i3n") 24 | # }) 25 | 26 | # test_that("fails well", { 27 | # skip_on_cran() 28 | 29 | # expect_error(eol(), "argument \"name\" is missing") 30 | # expect_error(eol(""), "'name' must be longer than 0 characters") 31 | # }) 32 | -------------------------------------------------------------------------------- /tests/testthat/test-flora_europaea.R: -------------------------------------------------------------------------------- 1 | test_that("flora_europaea", { 2 | skip_on_cran() 3 | 4 | sp <- c("Carpobrotus edulis", "Rosmarinus officinalis") 5 | vcr::use_cassette("flora_europaea", { 6 | aa <- flora_europaea(sp[1], messages = FALSE) 7 | bb <- flora_europaea(sp[2], messages = FALSE) 8 | }) 9 | 10 | expect_is(aa, "list") 11 | expect_named(aa, c('native', 'exotic', 'status_doubtful', 'occurrence_doubtful', 'extinct')) 12 | expect_equal(aa$native, NA_character_) 13 | expect_is(aa$exotic, "character") 14 | 15 | expect_is(bb, "list") 16 | expect_named(bb, c('native', 'exotic', 'status_doubtful', 'occurrence_doubtful', 'extinct')) 17 | expect_equal(bb$occurrence_doubtful, NA_character_) 18 | expect_is(bb$exotic, "character") 19 | }) 20 | 21 | test_that("flora_europaea fails well - species not found when searching GBIF", { 22 | skip_on_cran() 23 | 24 | sp <- "asdfadsf" 25 | vcr::use_cassette("flora_europaea_fail", { 26 | cc <- flora_europaea(sp, messages = FALSE) 27 | }) 28 | expect_null(cc) 29 | }) 30 | -------------------------------------------------------------------------------- /tests/testthat/test-gisd.R: -------------------------------------------------------------------------------- 1 | test_that("gisd", { 2 | skip_on_cran() 3 | 4 | sp <- c("Carpobrotus edulis", "Rosmarinus officinalis") 5 | vcr::use_cassette("gisd", { 6 | aa <- gisd(sp, messages = FALSE) 7 | }) 8 | 9 | expect_is(aa, "list") 10 | expect_named(aa, sp) 11 | expect_is(aa[[1]], "list") 12 | expect_is(aa[[2]], "list") 13 | }) 14 | 15 | test_that("gisd fails well - species not found when searching GBIF", { 16 | skip_on_cran() 17 | 18 | sp <- "asdfadsf" 19 | vcr::use_cassette("gisd_not_found", { 20 | aa <- gisd(sp, messages = FALSE) 21 | }) 22 | 23 | expect_is(aa, "list") 24 | expect_named(aa, sp) 25 | expect_equal(aa[[1]]$status, "Not in GISD") 26 | }) 27 | -------------------------------------------------------------------------------- /tests/testthat/test-griis.R: -------------------------------------------------------------------------------- 1 | test_that("griis", { 2 | skip_on_cran() 3 | 4 | vcr::use_cassette("griis", { 5 | aa <- griis(name = "Carpobrotus edulis") 6 | }) 7 | 8 | expect_is(aa, "data.frame") 9 | expect_named(aa, c('Species', 'Authority', 'Country', 'Kingdom', 10 | 'Environment.System', 'Origin', 'Evidence.of.Impacts', 11 | 'Verified', 'Date', 'Source')) 12 | }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test-is_native.R: -------------------------------------------------------------------------------- 1 | test_that("is_native - america, uses taxize::get_tsn", { 2 | skip_on_cran() 3 | 4 | sp <- c("Lavandula stoechas", "Carpobrotus edulis", 5 | "Rhododendron ponticum", "Alkanna lutea", "Anchusa arvensis") 6 | vcr::use_cassette("is_native", { 7 | aa <- is_native(sp[2], where = "Continental US", region = "america") 8 | }) 9 | 10 | expect_is(aa, "data.frame") 11 | expect_equal(NROW(aa), 1) 12 | expect_named(aa) 13 | expect_equal(aa$name, "Carpobrotus edulis") 14 | expect_equal(aa$origin, "Introduced") 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test-nsr.R: -------------------------------------------------------------------------------- 1 | test_that("nsr works", { 2 | skip_on_cran() 3 | 4 | vcr::use_cassette("nsr", { 5 | aa <- nsr("Pinus ponderosa", "United States") 6 | }) 7 | 8 | expect_is(aa, "data.frame") 9 | expect_named(aa) 10 | expect_equal(aa$species, "Pinus ponderosa") 11 | expect_equal(aa$native_status, "N") 12 | }) 13 | 14 | test_that("nsr fails well", { 15 | skip_on_cran() 16 | 17 | expect_error(nsr(), "argument \"country\" is missing") 18 | 19 | vcr::use_cassette("nsr_no_results", { 20 | bb <- nsr(species = "adadfd", country = "United States") 21 | }) 22 | 23 | expect_equal(NROW(bb), 1) 24 | }) 25 | --------------------------------------------------------------------------------