Files
uscogdata/man/cog_spending.Rd
T

47 lines
1.7 KiB
R

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spending.R
\name{cog_spending}
\alias{cog_spending}
\title{Summarized spending by category}
\usage{
cog_spending(
govid,
years,
category = NULL,
per_capita = FALSE,
adjust_to_year = NULL
)
}
\arguments{
\item{govid}{Character vector of `canonical_govid` values.}
\item{years}{Integer vector of years.}
\item{category}{Character vector of category names (from
`summary_categories.category`), or `NULL` for all categories.}
\item{per_capita}{If `TRUE`, adds `amt_per_capita_nominal` (and
`amt_per_capita_real` when `adjust_to_year` is set) using the per-year
Census F-33 population from `gov_population_yearly`. Result also gains
a `pop_source` column with values `"census_f33"` or `"unavailable"`
(the latter for gov types 4/5 and any row whose population is missing
in that year).}
\item{adjust_to_year}{Integer base year for CPI-U real-dollar conversion,
or `NULL` for nominal only.}
}
\value{
Tibble with columns `year`, `canonical_govid`, `gov_name`,
`spend_subtype`, `category`, `amt_nominal`, optional `amt_real`,
optional `amt_per_capita_nominal`, optional `amt_per_capita_real`,
optional `pop_source`, `codes_included`, `aggregate_fallback`, `notes`.
Carries a `provenance` attribute matching `inst/schemas/provenance-v1.json`.
}
\description{
One row per `(year, canonical_govid, spend_subtype, category)`. Amounts are
returned in **full U.S. dollars** (the raw corpus stores them in $1,000s;
this verb multiplies by 1000 so downstream code can freely rescale to
millions/billions). The conversion is recorded in the provenance attribute
under `transformations$units_conversion`.
}