Skip to content

Commit

Permalink
retrieve_ark function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Nov 23, 2024
1 parent 234ee7f commit 0c1dac6
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 3 deletions.
10 changes: 8 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: arktax
Title: What the Package Does (One Line, Title Case)
Title: Archive: NUCC Taxonomy Codesets, 2009 - 2024
Version: 0.0.0.9000
Authors@R:
person("Andrew", "Bruce", , "andrewallenbruce@gmail.com", role = c("aut", "cre", "cph"))
Expand All @@ -10,12 +10,18 @@ URL: https://github.com/andrewallenbruce/arktax,
https://andrewallenbruce.github.io/arktax/
BugReports: https://github.com/andrewallenbruce/arktax/issues
Imports:
data.table,
dplyr,
fs,
fuimus,
glue,
pins
Suggests:
roxyglobals,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
qs
Remotes:
andrewallenbruce/fuimus
Config/roxyglobals/filename: generated-globals.R
Config/roxyglobals/unique: TRUE
Config/testthat/edition: 3
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export(get_pin)
export(gh_raw)
export(list_pins)
export(mount_board)
export(retrieve_ark)
importFrom(data.table,year)
importFrom(dplyr,mutate)
importFrom(fs,path_package)
importFrom(fuimus,search_in_if)
importFrom(glue,glue)
importFrom(pins,board_folder)
importFrom(pins,board_url)
Expand Down
33 changes: 33 additions & 0 deletions R/arktax.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#' Get Taxomony Source File
#'
#' @param year `<int>` year of rvu source file; default is `2020`
#'
#' @param code `<chr>` Taxonomy code
#'
#' @returns `<tibble>` of search results
#'
#' @examples
#' retrieve_ark(2024, "101Y00000X")
#'
#' @importFrom dplyr mutate
#' @importFrom data.table year
#' @importFrom fuimus search_in_if
#'
#' @autoglobal
#'
#' @export
retrieve_ark <- function(year = 2024, code = NULL) {

ark <- get_pin("ark_taxonomy") |>
mutate(year = as.character(year(release_date)))

year <- match.arg(
arg = as.character(year),
choices = as.character(ark[["year"]]),
several.ok = TRUE)

ark <- search_in_if(ark, ark[["year"]], year)
ark <- search_in_if(ark, ark[["code"]], code)

return(ark)
}
2 changes: 2 additions & 0 deletions R/generated-globals.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by roxyglobals: do not edit by hand

utils::globalVariables(c(
# <retrieve_ark>
"release_date",
NULL
))
2 changes: 1 addition & 1 deletion man/arktax-package.Rd

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

23 changes: 23 additions & 0 deletions man/retrieve_ark.Rd

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

0 comments on commit 0c1dac6

Please sign in to comment.