Skip to content

Commit

Permalink
fix #66 rework searchbyterm and bigsearch to not define tons of param…
Browse files Browse the repository at this point in the history
…s in the fxn

but rather have user pass them in via ... and document the possible params
drop all others silently
update tests and readme
moved some docs to markdown
bump pkg version
  • Loading branch information
sckott committed Oct 10, 2019
1 parent bf4cc6f commit 0aba78e
Show file tree
Hide file tree
Showing 20 changed files with 640 additions and 430 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: Retrieve, map and summarize data from the 'VertNet.org'
parameters, including 'taxonomic' names, places, and dates. In addition,
there is an interface for conducting spatially delimited searches, and
another for requesting large 'datasets' via email.
Version: 0.7.0.9100
Version: 0.7.3.9100
Authors@R: c(
person("Scott", "Chamberlain",
role = c("aut", "cre"),
Expand All @@ -19,6 +19,8 @@ LazyData: true
URL: https://github.com/ropensci/rvertnet
BugReports: https://github.com/ropensci/rvertnet/issues
VignetteBuilder: knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Imports:
jsonlite (>= 1.5),
crul (>= 0.5.2),
Expand All @@ -28,7 +30,7 @@ Imports:
Suggests:
testthat,
knitr
RoxygenNote: 6.0.1
RoxygenNote: 6.1.1
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"
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ rmd2md:
cd vignettes;\
mv rvertnet_vignette.md rvertnet_vignette.Rmd

all:
${RSCRIPT} -e 'library(methods); devtools::compile_dll()'

test:
${RSCRIPT} -e 'library(methods); devtools::test()'

doc:
@mkdir -p man
${RSCRIPT} -e "library(methods); devtools::document()"

install:
R CMD INSTALL .
install: doc build
R CMD INSTALL . && rm *.tar.gz

build:
R CMD build .
Expand Down
39 changes: 12 additions & 27 deletions R/bigsearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,32 @@
#' tab-delimited text file.
#'
#' @export
#' @inheritParams searchbyterm
#' @param ... arguments, must be named, see [searchbyterm()] for details
#' @param rfile A name for the results file that you will download (character).
#' Required.
#' @param email An email address where you can be contacted when your records
#' are ready for download (character). Required.
#' @param ... Curl arguments passed on to \code{\link[crul]{HttpClient}}
#' @param messages (logical) Print progress and information messages.
#' Default: `TRUE`
#' @param callopts (named list) Curl arguments passed on to [crul::verb-GET]
#' @details \code{\link{bigsearch}} allows you to request records as a
#' tab-delimited text file. This is the best way to access a large number of
#' records, such as when your search results indicate that >1000 records are
#' available. You will be notified by email when your records are ready
#' for download.
#'
#' @section Reading data:
#' We suggest reading data in with \code{fread()} from the package
#' \pkg{data.table} - as it's very fast for the sometimes large datasets
#' We suggest reading data in with `data.table::fread()` - as it's very
#' fast for the sometimes large datasets
#' you will get from using this function, and is usually robust to
#' formatting issues.
#'
#' @return Prints messages on progress, but returns NULL
#' @references
#' \url{https://github.com/VertNet/webapp/wiki/The-API-search-function}
#' https://github.com/VertNet/webapp/wiki/The-API-search-function
#' @examples \dontrun{
#' # replace "big@@search.luv" with your own email address
#' bigsearch(genus = "ochotona", rf = "pikaRecords", email = "big@@search.luv")
#' bigsearch(genus = "ochotona", rfile = "pikaRecords", email = "big@@search.luv")
#'
#' # Pass in curl options for curl debugging
#' bigsearch(genus = "ochotona", rfile = "pikaRecords",
Expand All @@ -38,30 +40,13 @@
#' bigsearch(class = "aves", year = c(">=1976", "<=1986"),
#' rfile = "test-bigsearch1", email = "big@@search.luv")
#' }
bigsearch <- function(specificepithet = NULL, genus = NULL, family = NULL,
order = NULL, class = NULL, compact = FALSE, year = NULL, date = NULL,
mappable = NULL, error = NULL, continent = NULL, cntry = NULL,
stateprovince = NULL, county = NULL, island = NULL, igroup = NULL,
inst = NULL, id = NULL, catalognumber = NULL, collector = NULL,
type = NULL, hastypestatus = NULL, media = NULL, rank = NULL,
tissue = NULL, resource = NULL, rfile, email, messages = TRUE, ...) {

args <- rvc(
list(specificepithet = specificepithet, genus = genus,
family = family, order = order, class = class, eventdate = date,
mappable = ab(mappable), coordinateuncertaintyinmeters = error,
continent = continent, country = cntry, stateprovince = stateprovince,
county = county, island = island, islandgroup = igroup,
institutioncode = inst, occurrenceid = id,
catalognumber = catalognumber,
recordedby = collector, type = type, hastypestatus = hastypestatus,
media = ab(media), rank = rank, tissue = ab(tissue),
resource = resource))
args <- rvc(c(args, comb_var(year, "year")))
bigsearch <- function(..., rfile, email, messages = TRUE, callopts = list()) {
args <- process_args(list(...))
if (length(args) == 0) {
stop("You must use at least one parameter to specify your query",
call. = FALSE)
}
vertwrapper(fxn = "bigsearch", args = args, lim = NULL, rfile = rfile,
email = email, compact = FALSE, messages = messages, ...)
email = email, compact = FALSE, messages = messages,
callopts = callopts)
}
Loading

0 comments on commit 0aba78e

Please sign in to comment.