File: record.R

package info (click to toggle)
r-cran-ritis 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,156 kB
  • sloc: sh: 13; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#' Gets a record from an LSID
#'
#' @export
#' @inheritParams accepted_names
#' @param lsid lsid for a taxonomic group (character). Required.
#' @details Gets the partial ITIS record for the TSN in the LSID, found by comparing the
#'  TSN in the search key to the TSN field. Returns an empty result set if
#'  there is no match or the TSN is invalid.
#' @return a data.frame
#' @examples \dontrun{
#' record(lsid = "urn:lsid:itis.gov:itis_tsn:180543")
#' }
record <- function(lsid, wt = "json", raw = FALSE, ...) {
  out <- itis_GET("getRecordFromLSID", list(lsid = lsid), wt, ...)
  if (raw || wt == "xml") return(out)
  x <- tc(parse_raw(out))
  tibble::as_tibble(
    if (length(names(x)) < 2) {
      NULL
    } else {
      pick_cols(
        data.frame(x, stringsAsFactors = FALSE),
        c("authorship","genusPart","infragenericEpithet",
          "infraspecificEpithet","lsid","nameComplete","nomenclaturalCode",
          "rank","rankString","specificEpithet","uninomial","tsn"))
    }
  )
}