Skip to content

Commit

Permalink
Merge pull request #70 from usa-npn/docs-and-linting
Browse files Browse the repository at this point in the history
Non-code changes
  • Loading branch information
Aariq authored Dec 11, 2024
2 parents 571a46c + 3ce3ca2 commit 8aaf07c
Show file tree
Hide file tree
Showing 45 changed files with 1,732 additions and 1,453 deletions.
57 changes: 30 additions & 27 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
Package: rnpn
Title: Interface to the National 'Phenology' Network 'API'
Description: Programmatic interface to the
Web Service methods provided by the National 'Phenology' Network
(<https://usanpn.org/>), which includes data on various life history
events that occur at specific times.
Version: 1.2.9.9000
License: MIT + file LICENSE
Authors@R: c(
person("Jeff", "Switzer", role = c("aut", "cre"), email = "jeff@usanpn.org"),
person("Jeff", "Switzer", , "jeff@usanpn.org", role = c("aut", "cre")),
person("Scott", "Chamberlain", role = "aut"),
person("Lee", "Marsh", role= "aut"),
person("Lee", "Marsh", role = "aut"),
person("Kevin", "Wong", role = "aut"),
person("David", "LeBauer", role = "ctb"),
person("Eric R", "Scott", role = "ctb")
)
Depends: R (>= 3.5.0)
)
Description: Programmatic interface to the Web Service methods provided by
the National 'Phenology' Network (<https://usanpn.org/>), which
includes data on various life history events that occur at specific
times.
License: MIT + file LICENSE
URL: https://github.com/usa-npn/rnpn, http://usa-npn.github.io/rnpn/
BugReports: https://github.com/usa-npn/rnpn/issues
Depends:
R (>= 3.5.0)
Imports:
httr (>= 1.1.0),
jsonlite (>= 0.9.19),
data.table (>= 1.9.6),
tibble,
curl,
xml2,
httr2,
data.table (>= 1.9.6),
dplyr,
httr (>= 1.1.0),
httr2,
jsonlite (>= 0.9.19),
magrittr,
rlang,
magrittr
tibble,
xml2
Suggests:
ggplot2,
testthat (>= 3.0.0),
covr,
ggplot2,
knitr,
markdown,
rmarkdown,
RColorBrewer,
vcr,
withr,
rmarkdown,
sf,
terra
RoxygenNote: 7.3.2
Encoding: UTF-8
VignetteBuilder: knitr
URL: https://github.com/usa-npn/rnpn, http://usa-npn.github.io/rnpn/
BugReports: https://github.com/usa-npn/rnpn/issues
terra,
testthat (>= 3.0.0),
vcr,
withr
VignetteBuilder:
knitr
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export(npn_stations_by_state)
export(npn_stations_with_spp)
export(npn_stationsbystate)
export(npn_stationswithspp)
importFrom(httr2,"%>%")
importFrom(magrittr,"%>%")
importFrom(utils,URLencode)
importFrom(utils,download.file)
importFrom(utils,write.table)
12 changes: 6 additions & 6 deletions R/defunct.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ npn_stationswithspp <- function (...){
#' Defunct functions in rnpn
#'
#' \itemize{
#' \item \code{\link{npn_obsspbyday}}: Removed.
#' \item \code{\link{npn_allobssp}}: Removed.
#' \item \code{\link{npn_indspatstations}}: Removed.
#' \item \code{\link{npn_indsatstations}}: Removed.
#' \item \code{\link{npn_stationsbystate}}: Removed.
#' \item \code{\link{npn_stationswithspp}}: Removed.
#' \item [npn_obsspbyday()]: Removed.
#' \item [npn_allobssp()]: Removed.
#' \item [npn_indspatstations()]: Removed.
#' \item [npn_indsatstations()]: Removed.
#' \item [npn_stationsbystate()]: Removed.
#' \item [npn_stationswithspp()]: Removed.
#' }
#'
#' @name rnpn-defunct
Expand Down
18 changes: 9 additions & 9 deletions R/lookup_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
#' Look up species IDs by taxonomic or common name
#'
#' @export
#' @param name A scientific or common name
#' @param type One of common_name, genus, or species
#' @param fuzzy One of TRUE or FALSE, if FALSE, uses fuzzy search via agrep, if
#' FALSE, uses grep.
#' @return A data frame with species ID numbers based on the name and type parameters.
#' @param name A scientific or common name.
#' @param type One of `"common_name"`, `"genus"`, or `"species"`.
#' @param fuzzy Logical; if `TRUE`, uses fuzzy search via [agrep()], if
#' `FALSE`, uses [grep()].
#' @return A data frame with species ID numbers based on the name and type
#' parameters.
#' @examples \dontrun{
#' npn_lookup_names(name='Pinus', type='genus')
#' npn_lookup_names(name='pine', type='common_name')
#' npn_lookup_names(name='bird', type='common_name', fuzzy=TRUE)
#' }
npn_lookup_names <- function(name, type = 'genus', fuzzy = FALSE) {

if(is.null(pkg.env$species_list)){
assign("species_list",npn_species(),envir = pkg.env)
if (is.null(pkg.env$species_list)) {
assign("species_list", npn_species(), envir = pkg.env)
}

type <- match.arg(type, choices = c('common_name','genus','species'))
type <- match.arg(type, choices = c('common_name', 'genus', 'species'))

if (fuzzy) {
pkg.env$species_list[agrep(name, pkg.env$species_list[, type]), ]
Expand Down
Loading

0 comments on commit 8aaf07c

Please sign in to comment.