Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion R/get_crosswalk.R
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ get_available_crosswalks <- function() {
source_geography = geocorr_2022_geographies,
target_geography = "aiannh",
source_year = 2022L,
target_year = 2022L)
target_year = 2022L,
crosswalk_source = "geocorr")

geocorr_2022 <- dplyr::bind_rows(geocorr_2022, geocorr_2022_aiannh)

Expand Down
4 changes: 1 addition & 3 deletions R/get_nhgis_crosswalk.R
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,7 @@ years 2010, 2014, and 2015 (not ", target_year, ").")
stop(stringr::str_c(
"There is no available crosswalk between the specified geographies and years.")) }

if (is.null(api_key) || api_key == "") {
api_key = Sys.getenv("IPUMS_API_KEY")
}
api_key = Sys.getenv("IPUMS_API_KEY")
if (api_key == "") {
stop(
"API key required. Save your API key to the IPUMS_API_KEY environment
Expand Down
15 changes: 14 additions & 1 deletion tests/testthat/test-geoid_lengths.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ test_that("GeoCorr 2018 congressional district crosswalks have correct-length GE
test_that("CTData 2020-2022 crosswalks have correct-length GEOIDs", {
skip_if_offline()

for (geog in c("tract", "block_group", "county")) {
for (geog in c("tract", "block_group")) {
result <- get_crosswalk(
source_geography = geog,
target_geography = geog,
Expand All @@ -173,6 +173,19 @@ test_that("CTData 2020-2022 crosswalks have correct-length GEOIDs", {
}
})

test_that("CTData 2020-2022 county crosswalk has correct-length GEOIDs", {
skip_if_offline()
# the county path fetches 2020 county GEOIDs via tidycensus::get_acs()
skip_if(Sys.getenv("CENSUS_API_KEY") == "", "CENSUS_API_KEY not set")

result <- get_crosswalk(
source_geography = "county",
target_geography = "county",
source_year = 2020,
target_year = 2022)
assert_geoid_lengths(result, label = "ctdata county")
})

# ==============================================================================
# NHGIS GEOID length tests
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions vignettes/crosswalk.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ crosswalk. With no years specified, `get_crosswalk()` uses GeoCorr 2022
## save fetched crosswalks to a directory so repeat requests read from disk;
## see the Caching section at the end of this vignette
cache_dir <- file.path(tempdir(), "crosswalk-cache")
dir.create(cache_dir, recursive = TRUE, showWarnings = FALSE)

county_to_puma <- get_crosswalk(
source_geography = "county",
Expand Down
Loading