-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added nbn version of classificationa and started to incorporate to ge…
…neric classification fxn, #332
- Loading branch information
Showing
5 changed files
with
137 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Search UK National Biodiversity Network database for taxonomic classification | ||
#' | ||
#' @export | ||
#' | ||
#' @param q (character) The query terms(s) | ||
#' @param prefered (logical) Restrict search to preferred or any | ||
#' @param order (character) The order in which we should sort the results. Default: asc | ||
#' @param sort (character) Sort the results or not. | ||
#' @param start (integer/numeric) The page that the user wants to start displaying the results at. | ||
#' Default: 0 | ||
#' @param rows (integer/numeric) The number of rows to show in each page of search results. | ||
#' Default: 25 | ||
#' @param taxonOutputGroupKey (character) Vector of taxon output groups. | ||
#' @param all (logical) Get all results, overrides rows parameter if TRUE. Default: FALSE | ||
#' @param ... Further args passed on to \code{\link[httr]{GET}}. | ||
#' | ||
#' @author Scott Chamberlain, \email{myrmecocystus@@gmail.com} | ||
#' | ||
#' @examples \donttest{ | ||
#' nbn_classifcation(id="NHMSYS0000502940") | ||
#' | ||
#' # get id first, then pass to this fxn | ||
#' id <- get_nbnid("blue tit", rec_only = TRUE, rank = "Species") | ||
#' nbn_classifcation(id) | ||
#' | ||
#' library('httr') | ||
#' nbn_classifcation(id="NHMSYS0000502940", config=verbose()) | ||
#' } | ||
nbn_classifcation <- function(id, ...) | ||
{ | ||
url <- sprintf("https://data.nbn.org.uk/api/taxa/%s/taxonomy", id) | ||
nbn_class_GET(url, ...) | ||
} | ||
|
||
nbn_class_GET <- function(url, ...){ | ||
res <- GET(url, ...) | ||
stop_for_status(res) | ||
tt <- content(res, as = "text") | ||
jsonlite::fromJSON(tt, TRUE) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
% Generated by roxygen2 (4.0.2): do not edit by hand | ||
\name{nbn_classifcation} | ||
\alias{nbn_classifcation} | ||
\title{Search UK National Biodiversity Network database for taxonomic classification} | ||
\usage{ | ||
nbn_classifcation(id, ...) | ||
} | ||
\arguments{ | ||
\item{...}{Further args passed on to \code{\link[httr]{GET}}.} | ||
|
||
\item{q}{(character) The query terms(s)} | ||
|
||
\item{prefered}{(logical) Restrict search to preferred or any} | ||
|
||
\item{order}{(character) The order in which we should sort the results. Default: asc} | ||
|
||
\item{sort}{(character) Sort the results or not.} | ||
|
||
\item{start}{(integer/numeric) The page that the user wants to start displaying the results at. | ||
Default: 0} | ||
|
||
\item{rows}{(integer/numeric) The number of rows to show in each page of search results. | ||
Default: 25} | ||
|
||
\item{taxonOutputGroupKey}{(character) Vector of taxon output groups.} | ||
|
||
\item{all}{(logical) Get all results, overrides rows parameter if TRUE. Default: FALSE} | ||
} | ||
\description{ | ||
Search UK National Biodiversity Network database for taxonomic classification | ||
} | ||
\examples{ | ||
\donttest{ | ||
nbn_classifcation(id="NHMSYS0000502940") | ||
|
||
# get id first, then pass to this fxn | ||
id <- get_nbnid("blue tit", rec_only = TRUE, rank = "Species") | ||
nbn_classifcation(id) | ||
|
||
library('httr') | ||
nbn_classifcation(id="NHMSYS0000502940", config=verbose()) | ||
} | ||
} | ||
\author{ | ||
Scott Chamberlain, \email{myrmecocystus@gmail.com} | ||
} | ||
|