diff --git a/R/peers.R b/R/peers.R index 851060d..a4dc888 100644 --- a/R/peers.R +++ b/R/peers.R @@ -64,7 +64,7 @@ cog_find_peers <- function(target_govid, if (nrow(meta) == 0L) { cli::cli_abort(c( "govid {target_govid} not found in corpus.", - i = "v0.1 covers types 0-3 only (state/county/city/township); see vignette('coverage-scope')." + i = "uscogdata covers types 0-3 only (state/county/city/township)." )) } @@ -260,14 +260,17 @@ cog_find_peers <- function(target_govid, #' collection rate, and `n_units_reporting / n_units_collected` for category #' participation among collected units. #' -#' In FY2022 — a complete census year — Georgia reports 393 of 567 cities for -#' `category = "Police"`; the 174-city gap is overwhelmingly cities that -#' contract policing to the county sheriff, not non-response. +#' In FY2022, a census year, 393 of Georgia's 567 cities report +#' `category = "Police"`. Of the other 174, 32 were not collected and 142 were +#' collected with no Police rows. Contracting policing to the county sheriff is +#' one reason a city lands in the second group; the counters do not say how many +#' of the 142 do. #' -#' The comparison that *is* valid is the same category across a census year -#' (ending in 2 or 7) and a sample year, where the real-zero component is -#' roughly constant and the difference reflects the survey cycle. `is_census_year` -#' marks which is which. +#' A census year and a sample year collect different sets of governments, so +#' participation across the two mixes a change in which governments were +#' collected with any change in spending. Compare census years with each other, +#' or the same governments across years. `is_census_year` marks which is which, +#' and `vignette("coverage-counters")` has worked examples. #' @export cog_peer_compare <- function(target_govid, peers, category, years, per_capita = TRUE, adjust_to_year = NULL, diff --git a/R/rollup.R b/R/rollup.R index 819977e..aa1b6bb 100644 --- a/R/rollup.R +++ b/R/rollup.R @@ -80,14 +80,17 @@ #' collection rate, and `n_units_reporting / n_units_collected` for category #' participation among collected units. #' -#' In FY2022 — a complete census year — Georgia reports 393 of 567 cities for -#' `category = "Police"`; the 174-city gap is overwhelmingly cities that -#' contract policing to the county sheriff, not non-response. +#' In FY2022, a census year, 393 of Georgia's 567 cities report +#' `category = "Police"`. Of the other 174, 32 were not collected and 142 were +#' collected with no Police rows. Contracting policing to the county sheriff is +#' one reason a city lands in the second group; the counters do not say how many +#' of the 142 do. #' -#' The comparison that *is* valid is the same category across a census year -#' (ending in 2 or 7) and a sample year, where the real-zero component is -#' roughly constant and the difference reflects the survey cycle. `is_census_year` -#' marks which is which. +#' A census year and a sample year collect different sets of governments, so +#' participation across the two mixes a change in which governments were +#' collected with any change in spending. Compare census years with each other, +#' or the same governments across years. `is_census_year` marks which is which, +#' and `vignette("coverage-counters")` has worked examples. #' @export cog_geographic_rollup <- function(govids, category, years, per_capita = FALSE, adjust_to_year = NULL, diff --git a/R/search.R b/R/search.R index 806e6d8..856a9d3 100644 --- a/R/search.R +++ b/R/search.R @@ -102,8 +102,8 @@ cog_gov_search <- function(name = NULL, state = NULL, type = NULL, if (!is.null(type) && length(type) == 1L && .is_excluded_type(type)) { cli::cli_inform(c( - i = "v0.1 covers gov_types 0-3 (state/county/city/township) only.", - i = "Types 4 (special districts) and 5 (school districts) are excluded; see vignette('coverage-scope')." + i = "uscogdata covers gov_types 0-3 (state/county/city/township) only.", + i = "Types 4 (special districts) and 5 (school districts) are excluded pending validation." )) return(.empty_xwalk_tibble()) } diff --git a/man/cog_geographic_rollup.Rd b/man/cog_geographic_rollup.Rd index a24f312..e1191ea 100644 --- a/man/cog_geographic_rollup.Rd +++ b/man/cog_geographic_rollup.Rd @@ -105,13 +105,16 @@ category). Use `n_units_collected / n_units_expected` for the true collection rate, and `n_units_reporting / n_units_collected` for category participation among collected units. -In FY2022 — a complete census year — Georgia reports 393 of 567 cities for -`category = "Police"`; the 174-city gap is overwhelmingly cities that -contract policing to the county sheriff, not non-response. +In FY2022, a census year, 393 of Georgia's 567 cities report +`category = "Police"`. Of the other 174, 32 were not collected and 142 were +collected with no Police rows. Contracting policing to the county sheriff is +one reason a city lands in the second group; the counters do not say how many +of the 142 do. -The comparison that *is* valid is the same category across a census year -(ending in 2 or 7) and a sample year, where the real-zero component is -roughly constant and the difference reflects the survey cycle. `is_census_year` -marks which is which. +A census year and a sample year collect different sets of governments, so +participation across the two mixes a change in which governments were +collected with any change in spending. Compare census years with each other, +or the same governments across years. `is_census_year` marks which is which, +and `vignette("coverage-counters")` has worked examples. } diff --git a/man/cog_peer_compare.Rd b/man/cog_peer_compare.Rd index b76914f..b02c708 100644 --- a/man/cog_peer_compare.Rd +++ b/man/cog_peer_compare.Rd @@ -128,13 +128,16 @@ category). Use `n_units_collected / n_units_expected` for the true collection rate, and `n_units_reporting / n_units_collected` for category participation among collected units. -In FY2022 — a complete census year — Georgia reports 393 of 567 cities for -`category = "Police"`; the 174-city gap is overwhelmingly cities that -contract policing to the county sheriff, not non-response. +In FY2022, a census year, 393 of Georgia's 567 cities report +`category = "Police"`. Of the other 174, 32 were not collected and 142 were +collected with no Police rows. Contracting policing to the county sheriff is +one reason a city lands in the second group; the counters do not say how many +of the 142 do. -The comparison that *is* valid is the same category across a census year -(ending in 2 or 7) and a sample year, where the real-zero component is -roughly constant and the difference reflects the survey cycle. `is_census_year` -marks which is which. +A census year and a sample year collect different sets of governments, so +participation across the two mixes a change in which governments were +collected with any change in spending. Compare census years with each other, +or the same governments across years. `is_census_year` marks which is which, +and `vignette("coverage-counters")` has worked examples. } diff --git a/tests/testthat/test-peers.R b/tests/testthat/test-peers.R index 2044dc6..22db0c0 100644 --- a/tests/testthat/test-peers.R +++ b/tests/testthat/test-peers.R @@ -136,3 +136,10 @@ test_that("cog_peer_compare cohort_year is NA for bare character peers", { ) expect_true(all(is.na(r$cohort_year))) }) + +test_that("cog_find_peers unknown-govid error states the scope without a dead link", { + skip_if_no_corpus() + err <- expect_error(cog_find_peers("000000000000"), "not found in corpus") + expect_match(conditionMessage(err), "types 0-3") + expect_no_match(conditionMessage(err), "coverage-scope|v0\\.1") +}) diff --git a/tests/testthat/test-search.R b/tests/testthat/test-search.R index adb4959..8feeab1 100644 --- a/tests/testthat/test-search.R +++ b/tests/testthat/test-search.R @@ -63,6 +63,13 @@ test_that("cog_gov_search sorts by population desc", { expect_true(all(diff(nonNA) <= 0)) }) +test_that("cog_gov_search excluded-type message states the scope without a dead link", { + skip_if_no_corpus() + msgs <- testthat::capture_messages(cog_gov_search(type = 4L)) + expect_match(paste(msgs, collapse = " "), "types 0-3") + expect_no_match(paste(msgs, collapse = " "), "coverage-scope|v0\\.1") +}) + test_that("cog_gov_search rejects unknown type string", { expect_error(cog_gov_search(type = "galaxy"), "Unknown type") }) diff --git a/vignettes/coverage-counters.Rmd b/vignettes/coverage-counters.Rmd index 338739e..a3ef1c2 100644 --- a/vignettes/coverage-counters.Rmd +++ b/vignettes/coverage-counters.Rmd @@ -215,9 +215,9 @@ attr(police_2022, "provenance")$coverage On the published corpus, as of its 2026-10-26 build, the chunk returns 567 expected, 535 collected and 393 reporting. The 174 cities without Police rows split into 32 -that Census did not collect and 142 that were collected and have no Police rows. The -reference pages attribute most of the gap to cities that contract policing to the -county sheriff, and the counters place 142 of the 174 in the second group. +that Census did not collect and 142 that were collected and have no Police rows. +Contracting policing to the county sheriff is one reason a city lands in the second +group; the counters do not say how many of the 142 do. # Peer comparisons count peers only