Skip to content

Commit

Permalink
Updated package
Browse files Browse the repository at this point in the history
  • Loading branch information
sedv8808 committed Feb 27, 2024
1 parent ef4eb60 commit cbbbf10
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 216 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: neotoma2
Title: Working with the Neotoma Paleoecology Database
Date: 2024-02-16
Date: 2024-02-27
Version: 1.0.3
Authors@R:
c(person(given = "Dominguez Vidana",
Expand Down Expand Up @@ -48,4 +48,4 @@ Imports:
wk,
uuid,
tidyr
VignetteBuilder: knitr
VignetteBuilder: knitr
136 changes: 66 additions & 70 deletions R/filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,40 @@ utils::globalVariables(c("elev", "notes"))
#' is a nested object (it contains collection units, datasets, samples, etc.)
#' the degree to which filtering occurs depends on the amount of data contained
#' within the sites object. Filtering parameters include:
#' \itemize{
#' \item{"siteid"}{A numeric site identifier from the Neotoma Database}
#' \item{"sitename"}{The character string sitename.}
#' \item{"lat"}{A numeric latitude value.}
#' \item{"long"}{A numeric longitude value.}
#' \item{"altitude"}{The elevation of the site. Note that some sites do not
#' * `siteid` A numeric site identifier from the Neotoma Database.
#' * `sitename` The character string sitename.
#' * `lat` A numeric latitude value.
#' * `long` A numeric longitude value.
#' * `altitude` The elevation of the site. Note that some sites do not
#' include elevation information. For these an NA value appears, and they
#' would be removed when using an elevation filter.}
#' \item{"datasetid"}{A numeric datasetid from Neotoma.}
#' \item{"database"}{A character string naming the constituent database
#' from which the dataset is drawn.}
#' \item{"datasettype"}{A character string representing one of the many
#' dataset types within Neotoma.}
#' \item{"age_range_old"}{A dataset-level parameter indicating the oldest
#' date covered by the dataset chronology.}
#' \item{"age_range_young"}{A dataset-level parameter indicating the youngest
#' date covered by the dataset chronology.}
#' \item{"notes"}{Free-form dataset notes provided by the dataset PI(s),
#' analysts or data stewards.}
#' \item{"collectionunitid"}{A numeric collection unit identifier from
#' Neotoma.}
#' \item{"handle"}{A character string identifying the collection unit. These
#' are often shorter form names (originally a default 8 character length).}
#' \item{"collectionunitname"}{A character string identifying the collection
#' unit name.}
#' \item{"colldate"}{The date on which the collection unit was sampled. Many
#' of these are empty.}
#' \item{"location"}{A free-form character string indicating the location of
#' the collection unit within the site.}
#' \item{"waterdepth"}{A numeric depth at which the core was obtained.}
#' \item{"collunittype"}{A character string for the collection unit type.}
#' \item{"collectiondevice"}{A fixed vocabulary term for the collection
#' device.}
#' \item{"depositionalenvironment"}{A fixed vocabulary name for the
#' depositional environment.}
#'}
#' would be removed when using an elevation filter.
#' * `datasetid` A numeric datasetid from Neotoma.
#' * `database` A character string naming the constituent database
#' from which the dataset is drawn.
#' * `datasettype` A character string representing one of the many
#' dataset types within Neotoma.
#' * `age_range_old` A dataset-level parameter indicating the oldest
#' date covered by the dataset chronology.
#' * `age_range_young` A dataset-level parameter indicating the youngest
#' date covered by the dataset chronology.
#' * `notes` Free-form dataset notes provided by the dataset PI(s),
#' analysts or data stewards.
#' * `collectionunitid` A numeric collection unit identifier from
#' Neotoma.
#' * `handle` A character string identifying the collection unit. These
#' are often shorter form names (originally a default 8 character length).
#' * `collectionunitname` A character string identifying the collection
#' unit name.
#' * `colldate` The date on which the collection unit was sampled. Many
#' of these are empty.
#' * `location` A free-form character string indicating the location of
#' the collection unit within the site.
#' * `waterdepth` A numeric depth at which the core was obtained.
#' * `collunittype` A character string for the collection unit type.
#' * `collectiondevice` A fixed vocabulary term for the collection
#' device.
#' * `depositionalenvironment` A fixed vocabulary name for the
#' depositional environment.
#' @import sf
#' @import dplyr
#' @importFrom purrr map
Expand All @@ -59,42 +57,40 @@ filter <- function(x, ...) {
#' is a nested object (it contains collection units, datasets, samples, etc.)
#' the degree to which filtering occurs depends on the amount of data contained
#' within the sites object. Filtering parameters include:
#' \itemize{
#' \item{"siteid"}{A numeric site identifier from the Neotoma Database}
#' \item{"sitename"}{The character string sitename.}
#' \item{"lat"}{A numeric latitude value.}
#' \item{"long"}{A numeric longitude value.}
#' \item{"altitude"}{The elevation of the site. Note that some sites do not
#' * `siteid` A numeric site identifier from the Neotoma Database.
#' * `sitename` The character string sitename.
#' * `lat` A numeric latitude value.
#' * `long` A numeric longitude value.
#' * `altitude` The elevation of the site. Note that some sites do not
#' include elevation information. For these an NA value appears, and they
#' would be removed when using an elevation filter.}
#' \item{"datasetid"}{A numeric datasetid from Neotoma.}
#' \item{"database"}{A character string naming the constituent database
#' from which the dataset is drawn.}
#' \item{"datasettype"}{A character string representing one of the many
#' dataset types within Neotoma.}
#' \item{"age_range_old"}{A dataset-level parameter indicating the oldest
#' date covered by the dataset chronology.}
#' \item{"age_range_young"}{A dataset-level parameter indicating the youngest
#' date covered by the dataset chronology.}
#' \item{"notes"}{Free-form dataset notes provided by the dataset PI(s),
#' analysts or data stewards.}
#' \item{"collectionunitid"}{A numeric collection unit identifier from
#' Neotoma.}
#' \item{"handle"}{A character string identifying the collection unit. These
#' are often shorter form names (originally a default 8 character length).}
#' \item{"collectionunitname"}{A character string identifying the collection
#' unit name.}
#' \item{"colldate"}{The date on which the collection unit was sampled. Many
#' of these are empty.}
#' \item{"location"}{A free-form character string indicating the location of
#' the collection unit within the site.}
#' \item{"waterdepth"}{A numeric depth at which the core was obtained.}
#' \item{"collunittype"}{A character string for the collection unit type.}
#' \item{"collectiondevice"}{A fixed vocabulary term for the collection
#' device.}
#' \item{"depositionalenvironment"}{A fixed vocabulary name for the
#' depositional environment.}
#' }
#' would be removed when using an elevation filter.
#' * `datasetid` A numeric datasetid from Neotoma.
#' * `database` A character string naming the constituent database
#' from which the dataset is drawn.
#' * `datasettype` A character string representing one of the many
#' dataset types within Neotoma.
#' * `age_range_old` A dataset-level parameter indicating the oldest
#' date covered by the dataset chronology.
#' * `age_range_young` A dataset-level parameter indicating the youngest
#' date covered by the dataset chronology.
#' * `notes` Free-form dataset notes provided by the dataset PI(s),
#' analysts or data stewards.
#' * `collectionunitid` A numeric collection unit identifier from
#' Neotoma.
#' * `handle` A character string identifying the collection unit. These
#' are often shorter form names (originally a default 8 character length).
#' * `collectionunitname` A character string identifying the collection
#' unit name.
#' * `colldate` The date on which the collection unit was sampled. Many
#' of these are empty.
#' * `location` A free-form character string indicating the location of
#' the collection unit within the site.
#' * `waterdepth` A numeric depth at which the core was obtained.
#' * `collunittype` A character string for the collection unit type.
#' * `collectiondevice` A fixed vocabulary term for the collection
#' device.
#' * `depositionalenvironment` A fixed vocabulary name for the
#' depositional environment.
#' @import sf
#' @import dplyr
#' @importFrom purrr map
Expand Down
80 changes: 36 additions & 44 deletions R/get_sites.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,47 @@ parse_site <- function(result) {
#' ([api.neotomadb.org](https://api.neotomadb.org)) call for `sites`.
#' The call itself uses a SQL query which accepts any one of the following
#' parameters:
#' \itemize{
#' \item{`siteid`}{The unique site ID (integer) in Neotoma. Can be passed as a
#' vector of site IDs.}
#' \item{sitename}{The site name, or approximate match using the % wildcard.}
#' \item{database}{The constituent database for the record. See
#' `get_table("constituentdatabases")`}
#' \item{altmin}{The minimum altitude range for site elevation (in meters).}
#' \item{altmax}{The maximum altitude range for site elevation (in meters).}
#' \item{datasetid}{The unique dataset ID (integer) in Neotoma. Can be passed
#' as a vector of dataset IDs.}
#' \item{datasettype}{Neotoma contains data for a number of datasettypes.
#' * `siteid` The unique site ID (integer) in Neotoma. Can be passed as a
#' vector of site IDs.
#' * `sitename` The site name, or approximate match using the % wildcard.
#' * `database` The constituent database for the record. See `get_table("constituentdatabases")`
#' * `altmin` The minimum altitude range for site elevation (in meters).
#' * `altmax` The maximum altitude range for site elevation (in meters).
#' * `datasetid` The unique dataset ID (integer) in Neotoma. Can be passed
#' as a vector of dataset IDs.
#' * `datasettype` Neotoma contains data for a number of datasettypes.
#' This returns a subset of data types. For a complete list of available
#' datasettypes, run `neotoma2::get_table('datasettypes')`}
#' \item{doi}{The dataset DOI for a dataset contained within a site. Can be
#' passed as a vector of DOIs.}
#' \item{gpid}{The geopolitical name or identifier containing a site. Can be
#' passed as a vector of names.}
#' \item{keywords}{Keywords for samples within a set of sites. For example
#' "modern" indicates a sample within the record uses the keyword "modern".}
#' \item{contacts}{Contact names or IDs associated with a site.}
#' \item{ageyoung}{A minimum spanning age for the record, in years before
#' radiocarbon present (1950).}
#' \item{ageold}{A maximum spanning age for the record, in years before
#' radiocarbon present (1950).}
#' \item{ageof}{An age which must be contained within the range of sample ages
#' for a site.}
#' \item{taxa}{The names of taxa which must be present within samples in a
#' record.}
#' \item{all_data}{The API only downloads the first 25 records of the query.
#' For the complete records, use `all_data=TRUE`}
#' datasettypes, run `neotoma2::get_table('datasettypes')`
#' * `doi` The dataset DOI for a dataset contained within a site. Can be
#' passed as a vector of DOIs.
#' * `gpid` The geopolitical name or identifier containing a site. Can be
#' passed as a vector of names.
#' * `keywords` Keywords for samples within a set of sites. For example
#' "modern" indicates a sample within the record uses the keyword "modern".
#' * `contacts` Contact names or IDs associated with a site.
#' * `ageyoung` A minimum spanning age for the record, in years before
#' radiocarbon present (1950).
#' * `ageold` A maximum spanning age for the record, in years before
#' radiocarbon present (1950).
#' * `ageof` An age which must be contained within the range of sample ages
#' for a site.
#' * `taxa` The names of taxa which must be present within samples in a
#' record.
#' * `all_data` The API only downloads the first 25 records of the query.
#' For the complete records, use `all_data=TRUE`
#' This call will then return a data object that contains site metadata for one
#' or more sites, along with limited metadata describing the collection units
#' and datasets located at that site.
#' }
#' @returns The function returns either a single item of class `"try-error"`
#' describing the reason for failure (either misdefined parameters or an error
#' from the Neotoma API), or a table of sites, with rows corresponding to the
#' number of individual sites returned by the Neotoma API.
#' Each "site" object contains 6 parameters that can be accessed as well:
#' siteid, sitename, location, altitude, description,
#' limited collection units information.
#' * `loc` An `sf` object that describes site's location.
#' * `description`
#' * `collunits` limited information on collunits
#' * `loc` An `sf` object that describes site's location.
#' * `description`
#' * `collunits` limited information on collunits
#' @examples
#' \donttest{
#' ## Find all sites with a min altitude of 12m and a max altitude of 25m
Expand All @@ -108,7 +105,6 @@ parse_site <- function(result) {
#' sites_2500 <- get_sites(altmin=2500, all_data = TRUE)
#' ## To find all sites that contain the string "Alex%"
#' alex_sites <- get_sites(sitename="Alex%")
#'
#' ## To find sites in Brazil (again with default 25 records)
#' brazil <- '{"type": "Polygon",
#' "coordinates": [[
Expand Down Expand Up @@ -154,10 +150,8 @@ get_sites <- function(x = NA, ...) {
#' Each "site" object contains 6 parameters that can be accessed as well:
#' siteid, sitename, location, altitude, description,
#' limited collection units information.
#' \describe{
#' \item{loc}{ An `sf` object that describes site's location.}
#' \item{collunits}{ limited information on collunits}
#' }
#' * `loc` An `sf` object that describes site's location.
#' * `collunits` limited information on collunits
#' @export
get_sites.default <- function(...) { # nolint
oo <- options(scipen = 9999999)
Expand Down Expand Up @@ -229,8 +223,8 @@ get_sites.default <- function(...) { # nolint
#' Each "site" object contains 6 parameters that can be accessed as well:
#' siteid, sitename, location, altitude, description,
#' limited collection units information.
#' * `loc` An `sf` object that describes site's location.
#' * `collunits` limited information on collunits
#' * `loc` An `sf` object that describes site's location.
#' * `collunits` limited information on collunits
#' @examples {
#' ## Find all sites by numeric siteid:
#' sites <- get_sites(seq(1,3))
Expand Down Expand Up @@ -270,10 +264,8 @@ get_sites.numeric <- function(x, ...) {
#' Each "site" object contains 6 parameters that can be accessed as well:
#' siteid, sitename, location, altitude, description,
#' limited collection units information.
#' \itemize{
#' \item{loc}{ An `sf` object that describes site's location.}
#' \item{collunits}{ limited information on collunits}
#' }
#' * `loc` An `sf` object that describes site's location.
#' * `collunits` limited information on collunits
#' @export
get_sites.sites <- function(x, ...) {

Expand Down
66 changes: 33 additions & 33 deletions man/filter.Rd

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

Loading

0 comments on commit cbbbf10

Please sign in to comment.