% Generated by roxygen2: do not edit by hand % Please edit documentation in R/revenue.R \name{cog_revenue} \alias{cog_revenue} \title{Summarized revenue by category} \usage{ cog_revenue( govid, years, category = NULL, per_capita = FALSE, adjust_to_year = NULL, basis = c("harmonized", "raw"), recipe = NULL, complete = FALSE ) } \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.} \item{basis}{`"harmonized"` (default) sums item codes through the cross-vintage harmonization mapping (folding series-break-affected codes onto a comparable target and excluding aggregate / discontinued rows -- see the `harmonization` block in `cog_explain()`); `"raw"` reproduces the pre-Phase-R2 behavior (published item codes, no folding). On a corpus with `schema_version < 5` (no harmonization tables), `basis` silently resolves to `"raw"` when left at its default and the resolution is recorded in the provenance; explicitly passing `basis = "harmonized"` on such a corpus aborts. Ignored when `recipe` is set (see below).} \item{recipe}{Optional harmonization recipe id (see [cog_recipes()]) for multi-code cross-vintage series that a 1:1 harmonized_code mapping can't express (e.g. a wide-era aggregate that only splits into leaf codes in the modern era). Mutually exclusive with `category`. The result's subtype column reads `"recipe"` and `category` reads the recipe's label. Requires `schema_version >= 5`. A recipe query bypasses `basis` entirely (it joins `long` directly rather than going through the `*_annotated`/`*_annotated_harmonized` views), so the `basis` argument is ignored and the result's provenance reports `basis = "recipe"` with an inert `harmonization` block (`applied = FALSE`, pointing at the `recipe` block instead) rather than a possibly-misleading `"harmonized"`/`"raw"` value.} \item{complete}{If `TRUE`, fill the requested grid so that a cell the corpus does not carry still appears, labelled with **why** it is missing, and add a `value_source` column to every row: * `"reported"` — the corpus carries this cell. * `"census_zero"` — dense-source year (`<= FY2011`), cell absent: Census published `$0`. `amt_nominal` is `0`. * `"not_reported"` — sparse-source year (`>= FY2012`), cell absent: the government did not report, and the value is unknown. `amt_nominal` is `NA`, **not** `0` — writing a zero there would invent data. The grid comes from the corpus's `code_set` table, scoped to each government's own type, so a county is never filled with cells only a state can report. Reported rows are passed through untouched. Defaults to `FALSE` (the historical behaviour: absent cells simply do not appear). Needs a corpus published from 2026-07-29 onward, which is when `representation`/`code_set` began shipping; aborts with class `uscogdata_representation_unavailable` otherwise. Not available with `recipe` or with `expenditure_concept = "total"` (class `uscogdata_complete_unsupported`) — neither draws its cells from `code_set`.} } \value{ Tibble with columns `year`, `canonical_govid`, `gov_name`, `revenue_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`, and `value_source` when `complete = TRUE`. } \description{ Mirror of [cog_spending()] for revenue categories. One row per `(year, canonical_govid, revenue_subtype, category)`. Amounts are returned in **full U.S. dollars** (raw Census values are in $1,000s; this verb multiplies by 1000 and records the conversion in `provenance`). }