Repository navigation
docs: add a vignette on reading provenance$coverage (#72) - #2
Conversation
vignettes/coverage-counters.Rmd explains the three per-year counters that cog_geographic_rollup() and cog_peer_compare() attach as provenance$coverage, using the definitions in .coverage_table(), R/rollup.R and R/peers.R: n_units_expected (the ids passed, or the peers), n_units_collected (of those, how many have any row in the spending long view that year) and n_units_reporting (of those, how many have a row in the requested category). It splits the named governments into three groups, defines the collection rate and category participation, and shows that reporting / expected is their product. The evaluated chunks run against the bundled fixture and say so: Georgia cities and Police across FY2011, FY2012, FY2019 and FY2020, a peer comparison, and the census, consistent and per_capita effects. The FY2022 example from the reference pages needs the published corpus and is not evaluated, following population-denominators.Rmd. The article is added to the pkgdown Concepts index. Closes #72 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qbe6u2h83wgZdTgJgE4Xh5
|
Thanks for this — and one thing worth knowing before it happens. This repository is a mirror. Development happens on Gitea at Because that merge preserves your commits at their original SHAs, GitHub will
If it is not going to be merged, you will get an actual reply saying so. Substantial contributions get a Full details: CONTRIBUTING.md. |
Checked against the published corpus (build of 2026-10-26) through the public API: - FY2022 Georgia cities, Police: 567 expected, 535 collected, 393 reporting. The 174-city gap is 32 not collected and 142 collected with no Police rows. The FY2022 section now states the split. - All US cities: Police participation among collected cities is 0.70, 0.73 and 0.72 in FY2012, FY2017 and FY2022, and 0.93 to 0.95 in every sample year FY2013-FY2023. Among the 3,867 cities collected in both FY2022 and FY2021 it is 0.929 and 0.935; Fire, Libraries and Housing & Community move by 0.01 or less on the same cities. A census year and a sample year collect different sets of governments, so the census-vs-sample section now recommends comparing census years with each other, or the same governments across years, and adds a fixture chunk that measures participation over the 99 Georgia cities collected in both FY2012 and FY2019 (0.97 and 0.94). The fixture caveat now says what data-raw/regenerate_fixture_corpus.R does: each fixture year is a full copy of the published partition. Its FY2012 and FY2019 Georgia Police counts match the published corpus; the newer crosswalk lists 567 Georgia cities where the fixture lists 566. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qbe6u2h83wgZdTgJgE4Xh5
Gitea issue #72
What changed
vignettes/coverage-counters.Rmd. It covers:provenance$coverage.coverage_table(),R/rollup.RandR/peers.Rreporting / expectedshown as their productcoverage = "census",coverage = "consistent"andper_capita = TRUEchange the countersis_census_year, and a summary_pkgdown.yml:coverage-countersadded to the "Concepts" articles index.Definitions I took from the code, not from the counter names:
n_units_collectedcomes from the spending long view:spending_long_harmonized, orspending_longunderbasis = "raw". That view holds every non-aggregate, non-intergovernmental expenditure row. The vignette demonstrates the definition by rebuilding the counts fromcog_spending(..., category = "All Categories", expenditure_concept = "direct").cog_peer_compare(),n_units_expectedislength(peer_govids)andn_units_reportingcounts peer rows only, so the target appears in none of the three counters.cog_geographic_rollup(), thecoverage = "consistent"filter and theper_capita = TRUErow drop both run beforen_units_reportingis counted. Neither touchesn_units_expectedorn_units_collected.Census year vs sample year: resolved against the published corpus
The draft version of this PR asked which was right: this vignette, or the "Reading
coverage" sections ofR/peers.RandR/rollup.R. Those sections say the valid comparison is "the same category across a census year … and a sample year, where the real-zero component is roughly constant." I checked the published corpus (build of 2026-10-26) through the public API.Among the 3,867 cities collected in both FY2022 and FY2021, the gap disappears:
FY2022 against FY2023 gives the same result. Georgia cities alone, FY2007–FY2023: participation is 0.72 to 0.75 in every census year and 0.93 to 1.00 in every sample year.
The collected-but-no-rows group is not constant between a census year and a sample year. Sample years collect a different, larger set of cities. The vignette (commit e3cb9d5) therefore recommends comparing census years with each other, or the same governments across years. It also adds a fixture chunk that does the second: 99 Georgia cities collected in both FY2012 and FY2019, with participation 0.97 and 0.94.
The roxygen in
R/peers.RandR/rollup.Rstill says the opposite. That fix is outside #72 and is not in this PR.How it was built and tested
Locally, on Ubuntu 24.04 with R 4.3.3 and duckdb 2.0.0 (compiled from CRAN source). The sandbox could not reach
extensions.duckdb.org, so I built and checked on a scratch copy withcog_open()'sINSTALL httpfs; LOAD httpfs;line removed. The fixture is a local path and never useshttpfs. That patch is not in any commit.First commit (4bfb6eb):
R CMD build --no-manualthenR CMD check --no-manual: the vignette builds, and its code runs. Tests pass.en_US.UTF-8locale..roborev.tomlis a hidden file in the tarball.pkgdown::check_pkgdown(): no problems.Second commit (e3cb9d5):
rmarkdown::html_vignette().R CMD build --no-manualrebuilt all vignettes ("creating vignettes ... OK").R CMD checklocally again. CI runs it on this push.Fixture caveat: every evaluated chunk runs against the fixture. The vignette states what
data-raw/regenerate_fixture_corpus.Rdoes: each fixture year is a full copy of the published partition, from the 2026-08-03 build. The fixture's FY2012 and FY2019 Georgia Police counts (534/398 and 103/96) match the published corpus. Its crosswalk lists 566 Georgia cities, where the published corpus lists 567. The FY2022 chunk iseval = FALSEwith a "Not run" comment, followingpopulation-denominators.Rmd.Checked against output:
Still not verified
category = "Police". Its Police spending is a real zero." This illustrates the mechanism using the reference pages' example. I did not check any specific city.R/coverage.Rand the reference pages.per_capita = TRUEsentences and the sentence aboutcog_peer_compare()exempting the target from"consistent"are read from the code. No chunk shows them.Where the example comes from: the task description called this "the FY2012 Georgia Police example already in the roxygen and README". The roxygen gives FY2022 (393 of 567), and
README.mdhas no Georgia Police example.Noticed, not changed
R/peers.RandR/rollup.Rsay a census year vs a sample year is the valid comparison. The published corpus contradicts this (see above). It needs a follow-up issue.cog_find_peers()andcog_gov_search()point users atvignette('coverage-scope'), which does not exist.🤖 Generated with Claude Code
https://claude.ai/code/session_01Qbe6u2h83wgZdTgJgE4Xh5