From 5f51fdc681ad06e7074767c66de24ac76cb529f4 Mon Sep 17 00:00:00 2001 From: camille-s Date: Fri, 28 Jun 2024 12:33:39 -0400 Subject: [PATCH] Fix bug that lost 2022 PUMAs --- R/census_helpers.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/census_helpers.R b/R/census_helpers.R index 0322566..0601267 100644 --- a/R/census_helpers.R +++ b/R/census_helpers.R @@ -185,11 +185,17 @@ census_pumas <- function(src, table, year, pumas, counties, state, dataset, key, if (identical(pumas, "all")) { xw <- county_x_state(state, counties) } else { + # joining with county_x_state doesn't work here for 2022 because pumas aren't subsets of counties anymore xw <- county_x_state(state, "all") fetch <- dplyr::filter(fetch, GEOID %in% pumas) } + fetch$county_geoid <- substr(fetch$GEOID, 1, 5) - fetch <- dplyr::inner_join(fetch, xw, by = "county_geoid") + + # don't filter if CT in 2022+ + if (!(year >= 2022 & state == "09")) { + fetch <- dplyr::inner_join(fetch, xw, by = "county_geoid") + } fetch$county_geoid <- NULL fetch$NAME <- fetch$GEOID fetch