Skip to content

Commit

Permalink
use documented dwc terms dataset instead of inst txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
slager committed Feb 11, 2024
1 parent a28c3b7 commit 9ded0a2
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 191 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ revdep/library.noindex
^doc$
^Meta$
^vignettes/figure$
^data-raw$
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ URL: https://github.com/ropensci/rvertnet (devel)
BugReports: https://github.com/ropensci/rvertnet/issues
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Depends:
R (>= 2.10)
Imports:
jsonlite (>= 1.5),
crul (>= 0.5.2),
Expand All @@ -38,3 +40,4 @@ X-schema.org-applicationCategory: Data Access
X-schema.org-keywords: species, occurrences, biodiversity, maps, vertnet, mammals, mammalia, specimens
X-schema.org-isPartOf: "https://ropensci.org"
VignetteBuilder: knitr
LazyData: true
8 changes: 8 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' Darwin core terms
#'
#' Used internally by [vert_id()] to filter data to Darwin core terms only. Get in touch with us if these terms need correcting or are out of date.
#'
#' @format ## `simple_dwc_terms`
#' A character vector
#' @source <https://raw.githubusercontent.com/tdwg/dwc/master/dist/simple_dwc_vertical.csv>
"simple_dwc_terms"
14 changes: 6 additions & 8 deletions R/vert_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
#' (i.e., with http://...), while others start with `urn`.
#'
#' Internally in this function we filter data to darwin core terms only. To
#' see what terms we use, do
#' \code{readLines(
#' system.file("extdata", "simple_dwc_terms.txt", package = "rvertnet"))}.
#' Get in touch with us if these terms need correcting/are out of date. The
#' terms are from
#' https://github.com/tdwg/dwc/blob/master/dist/simple_dwc_horizontal.csv
#' see what terms we use, see:
#' \code{print(simple_dwc_terms)}.
#'
#' See documentation for more information:
#' \code{?simple_dwc_terms}
#'
#' @examples \dontrun{
#' vert_id(ids = "urn:catalog:CM:Herps:116520")
Expand Down Expand Up @@ -48,8 +47,7 @@ vert_id <- function(ids, compact = TRUE, messages = TRUE, ...) {
result
}
names(df) <- tolower(names(df))
res <- get_terms()
df <- df[ , names(df) %in% res ]
df <- df[ , names(df) %in% rvertnet::simple_dwc_terms]
if (compact) {
df <- df[ , !sapply(df, function(x) all(is.na(x))) ]
}
Expand Down
9 changes: 1 addition & 8 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ vertwrapper <- function(fxn = "", args = NULL, lim = NULL, rfile = NULL,

mssg <- function(v, ...) if (v) message(...)

get_terms <- function() {
readLines(
system.file("extdata", "simple_dwc_terms.txt", package = "rvertnet")
)
}

vert_GET <- function(fxn="searchbyterm", args, limit = 1000, messages = TRUE,
only_dwc = TRUE, callopts = list(), ...) {
cursor <- NULL
Expand Down Expand Up @@ -70,8 +64,7 @@ vert_GET <- function(fxn="searchbyterm", args, limit = 1000, messages = TRUE,
}
names(df) <- tolower(names(df))
if (only_dwc) {
res <- get_terms()
df <- df[ , names(df) %in% res ]
df <- df[ , names(df) %in% rvertnet::simple_dwc_terms]
}
mssg(messages, paste("\nLast Query URL: \"", URLdecode(tt$url), "\"", sep = ""))
mssg(messages, paste("\nMatching records:", NROW(df), "returned,", avail, "available", sep = " "))
Expand Down
6 changes: 6 additions & 0 deletions data-raw/simple_dwc_terms.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
simple_dwc_terms <-
tolower(
readLines(
'https://raw.githubusercontent.com/tdwg/dwc/master/dist/simple_dwc_vertical.csv'))

usethis::use_data(simple_dwc_terms, overwrite = TRUE)
Binary file added data/simple_dwc_terms.rda
Binary file not shown.
169 changes: 0 additions & 169 deletions inst/extdata/simple_dwc_terms.txt

This file was deleted.

22 changes: 22 additions & 0 deletions man/simple_dwc_terms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions man/vert_id.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9ded0a2

Please sign in to comment.