Skip to content

Commit

Permalink
fixed occ_options and occ_names_options fxns removing getting
Browse files Browse the repository at this point in the history
ecoengine and antweb stuff as they are not imported anymore and user may not have them
  • Loading branch information
sckott committed Apr 20, 2017
1 parent d021564 commit 429921c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 30 deletions.
22 changes: 11 additions & 11 deletions R/occ_names_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @export
#'
#' @param from (character) Data source to get data from, any combination of
#' gbif, bison, and/or ecoengine. Case doesn't matter.
#' gbif or bison. Case doesn't matter.
#' @param where (character) One of console (print to console) or html
#' (opens help page, if in non-interactive R session, prints help to console).
#'
Expand All @@ -15,14 +15,16 @@
#'
#' Note that the from parameter is lowercased within the function and is
#' called through `match.arg` first, so you can match on unique partial
#' strings too (e.g., 'e' for 'ecoengine').
#' strings too (e.g., 'rb' for 'rbison').
#'
#' For `ecoengine`, we use internal helper functions and don't import
#' the package, but see `?ecoengine::ee_search` for help on parameters.
#' @examples \dontrun{
#' # opens up documentation for this function
#' occ_names_options()
#'
#' # Open up documentation for the appropriate search function for each source
#' occ_names_options('gbif')
#' occ_names_options('ecoengine')
#' occ_names_options('bison')
#'
#' # Or open in html version
Expand All @@ -31,12 +33,11 @@

occ_names_options <- function(from = 'gbif', where="console"){
from <- tolower(from)
from <- match.arg(from, choices=c('gbif','bison','ecoengine'))
pkgname <- switch(from, gbif='rgbif', bison='rbison', ecoengine='ecoengine')
from <- match.arg(from, choices = c('gbif', 'bison'))
pkgname <- switch(from, gbif = 'rgbif', bison = 'rbison')
check_for_package(pkgname)
fxn <- switch(from, gbif='name_lookup', bison='bison_tax',
ecoengine='ee_search')
if(where == "console"){
fxn <- switch(from, gbif = 'name_lookup', bison = 'bison_tax')
if (where == "console") {
res <- tools::Rd_db(pkgname)
fxnrd <- res[[sprintf('%s.Rd', fxn)]]
params <- fxnrd[ which(rd_tags(fxnrd) == "\\arguments") ]
Expand All @@ -47,13 +48,12 @@ occ_names_options <- function(from = 'gbif', where="console"){
}
})))
cat(sprintf("%s parameters:", fxn), sapply(pars, spocc_wrap,
indent=6, width=80,
indent = 6, width = 80,
USE.NAMES = FALSE), sep = "\n")
} else {
showit <- switch(from,
gbif = "?rgbif::name_lookup",
bison = "?rbison::bison_tax",
ecoengine = "?ecoengine::ee_search")
bison = "?rbison::bison_tax")
eval(parse(text = showit))
}
}
27 changes: 16 additions & 11 deletions R/occ_options.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @export
#' @param from (character) Data source to get data from, any combination of
#' gbif, bison, ebird, AntWeb, idigibio and/or ecoengine. Case doesn't matter.
#' gbif, bison, ebird, idigibio and/or vertnet. Case doesn't matter.
#' inat is not included here, see that package's help docs.
#' @param where (character) One of console (print to console) or html (opens
#' help page, if in non-interactive R session, prints help to console).
Expand All @@ -14,16 +14,25 @@
#'
#' Note that the from parameter is lowercased within the function and is
#' called through match.arg first, so you can match on unique partial
#' strings too (e.g., 'e' for 'ecoengine').
#' strings too (e.g., 'rv' for 'rvertnet').
#'
#' For some data sources we don't import the canonical package, but instead
#' have our own intenral helper functions and the package in question is
#' not imported, but we do suggest seeing the help for the package on
#' their parameters:
#'
#' \itemize{
#' \item **AntWeb**: `?AntWeb::aw_data`
#' \item **ecoengine**: `?ecoengine::ee_observations`
#' }
#'
#' For others,
#' @examples \dontrun{
#' # opens up documentation for this function
#' occ_options()
#'
#' # Open up documentation for the appropriate search function for each source
#' occ_options('gbif')
#' occ_options('ecoengine')
#' occ_options('AntWeb')
#' occ_options('antweb')
#' occ_options('ebird')
#' occ_options('bison')
#' occ_options('idigbio')
Expand All @@ -35,14 +44,12 @@

occ_options <- function(from = 'gbif', where="console"){
from <- tolower(from)
from <- match.arg(from, choices = c('gbif', 'bison', 'ebird', 'ecoengine',
'antweb', 'idigbio', 'vertnet'))
from <- match.arg(from, choices = c('gbif', 'bison', 'ebird',
'idigbio', 'vertnet'))
pkgname <- switch(from, gbif = 'rgbif', bison = 'rbison', ebird = 'rebird',
ecoengine = 'ecoengine', antweb = 'AntWeb',
idigbio = 'ridigbio', vertnet = 'rvertnet')
check_for_package(pkgname)
fxn <- switch(from, gbif = 'occ_data', bison = 'bison', ebird = 'ebirdregion',
ecoengine = 'ee_observations', antweb = 'aw_data',
idigbio = 'idig_search_records', vertnet = 'vertsearch')
if (where == "console") {
res <- tools::Rd_db(pkgname)
Expand All @@ -62,8 +69,6 @@ occ_options <- function(from = 'gbif', where="console"){
gbif = "?rgbif::occ_data",
bison = "?rbison::bison",
ebird = "?rebird::ebirdregion",
ecoengine = "?ecoengine::ee_observations",
antweb = "?AntWeb::aw_data",
idigbio = "?ridigbio::idig_search_records",
vertnet = "?rvertnet::vertsearch")
eval(parse(text = showit))
Expand Down
8 changes: 5 additions & 3 deletions man/occ_names_options.Rd

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

19 changes: 14 additions & 5 deletions man/occ_options.Rd

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

0 comments on commit 429921c

Please sign in to comment.