feat: cog_categories
Discovery verb over the summary_categories view, grouped one row per (category, subtype). Parallels cog_gov_search: analysts use it to find the valid `category` values to pass into cog_spending(), cog_revenue(), cog_geographic_rollup(). Columns: category, category_type, subtype, n_codes, item_codes (comma-separated, alphabetical). Optional filters: type = NULL | "spending" | "revenue" pattern = regex matched case-insensitively on category The user-facing "spending" alias is translated internally to the corpus-native "expenditure" so callers don't have to learn Census vocabulary, while the returned category_type column preserves the native value for auditability. Also: fix @noRd placement in session.R so devtools::document() stops warning. Tests: +16 new / 181 total pass. check 0E/0W/0N.
This commit is contained in:
+10
-10
@@ -33,13 +33,13 @@ cog_open <- function(url = .resolve_url(),
|
||||
.uscogdata_env$con
|
||||
}
|
||||
|
||||
# Coerce an input to a character vector of canonical_govid values.
|
||||
# Accepts either a character vector (returned as-is after `as.character`)
|
||||
# or a data.frame / tibble with a `canonical_govid` column (such as the
|
||||
# output of cog_gov_search() or cog_find_peers()) — in that case the
|
||||
# column is extracted so results from discovery verbs can pipe directly
|
||||
# into the query verbs.
|
||||
#' @noRd
|
||||
#' Coerce an input to a character vector of canonical_govid values.
|
||||
#' Accepts either a character vector (returned as-is after `as.character`)
|
||||
#' or a data.frame / tibble with a `canonical_govid` column (such as the
|
||||
#' output of [cog_gov_search()] or [cog_find_peers()]) — in that case the
|
||||
#' column is extracted so results from discovery verbs can pipe directly
|
||||
#' into the query verbs.
|
||||
.coerce_govid_input <- function(x, arg = "govid") {
|
||||
if (is.data.frame(x)) {
|
||||
if (!"canonical_govid" %in% names(x)) {
|
||||
@@ -58,11 +58,11 @@ cog_open <- function(url = .resolve_url(),
|
||||
as.character(x)
|
||||
}
|
||||
|
||||
# Check which of the supplied govids exist in canonical_fips_xwalk.
|
||||
# Emits a cli message listing any missing ones alongside a pointer to the
|
||||
# v0.1 scope explanation; returns both sets so callers can attach them to
|
||||
# provenance.
|
||||
#' @noRd
|
||||
#' Check which of the supplied govids exist in canonical_fips_xwalk.
|
||||
#' Emits a cli message listing any missing ones alongside a pointer to the
|
||||
#' v0.1 scope explanation; returns both sets so callers can attach them to
|
||||
#' provenance.
|
||||
.check_govids_in_scope <- function(govids) {
|
||||
govids <- unique(as.character(govids))
|
||||
if (length(govids) == 0L) return(list(found = character(0), missing = character(0)))
|
||||
|
||||
Reference in New Issue
Block a user