-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #122 usda api is down for good - defunct that fxn - update readme
- Loading branch information
Showing
9 changed files
with
118 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
#' Defunct functions in traits | ||
#' | ||
#' These functions have been removed. See package \code{originr}. | ||
#' These functions have been removed. See package `originr` | ||
#' | ||
#' \itemize{ | ||
#' \item \code{\link{eol_invasive_}}: This function has moved to a new package. | ||
#' See \code{eol} in \code{originr} | ||
#' \item \code{\link{fe_native}}: This function has moved to a new package. | ||
#' See \code{flora_europaea} in \code{originr} | ||
#' \item \code{\link{g_invasive}}: This function has moved to a new package. | ||
#' See \code{gisd} in \code{originr} | ||
#' \item \code{\link{is_native}}: This function has moved to a new package. | ||
#' See \code{is_native} in \code{originr} | ||
#' } | ||
#' - `eol_invasive_`: This function has moved to a new package. | ||
#' See `originr::eol` | ||
#' - `fe_native`: This function has moved to a new package. | ||
#' See `originr::flora_europaea` | ||
#' - `g_invasive`: This function has moved to a new package. | ||
#' See `originr::gisd` | ||
#' - `is_native`: This function has moved to a new package. See | ||
#' `originr::is_native` | ||
#' - `tr_usda`: the API behind this function is down for good | ||
#' | ||
#' @name traits-defunct | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,11 @@ | ||
#' USDA plants data | ||
#' | ||
#' DEFUNCT | ||
#' | ||
#' @export | ||
#' @param query (character) query terms in a named list | ||
#' @param limit (integer) number of records to return | ||
#' @param offset (integer) record number to start at | ||
#' @param fields (character) vector of fields to return, case sensitive | ||
#' @param ... Curl options passed on to [crul::HttpClient()] | ||
#' @return list, with metadata fields ("count", "returned", "citation", | ||
#' "terms"), and a data.frame in "data" | ||
#' @details beware: this data is a bit old, from a dump of their data | ||
#' from a while back. | ||
#' @references https://plantsdb.xyz, https://github.com/sckott/usdaplantsapi | ||
#' @examples \dontrun{ | ||
#' tr_usda(query = list(genus = "Magnolia")) | ||
#' tr_usda(query = list(genus = "Magnolia", species = "grandiflora")) | ||
#' | ||
#' tr_usda(limit = 30) | ||
#' tr_usda(limit = 3) | ||
#' tr_usda(limit = 3, offset = 3) | ||
#' | ||
#' tr_usda(fields = c('Id', 'Symbol', 'Genus', 'Species')) | ||
#' } | ||
tr_usda <- function(query = list(), limit = 30, offset = 0, fields = NULL, ...) { | ||
cli <- crul::HttpClient$new(url = usda_base) | ||
if (!is.null(fields)) fields <- paste0(fields, collapse = ",") | ||
args <- traitsc(c(query, limit = limit, offset = offset, fields = fields)) | ||
res <- cli$get("search", query = args, ...) | ||
res$raise_for_status() | ||
tmp <- jsonlite::fromJSON(res$parse("UTF-8")) | ||
tmp$data <- tibble::as_tibble(tmp$data) | ||
return(tmp) | ||
#' @param ... ignored | ||
#' @rdname tr_usda-defunct | ||
#' @keywords internal | ||
tr_usda <- function(...) { | ||
.Defunct(msg = "the plantsdb.xyz API is down for good") | ||
} | ||
|
||
usda_base <- "https://plantsdb.xyz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.