tidycensus icon indicating copy to clipboard operation
tidycensus copied to clipboard

Issues with downloading replicate weights for Florida microdata

Open ghutton7 opened this issue 1 month ago • 2 comments

I am trying to use get_pums() to download Florida microdata from the ACS for the following variables ("BLD", "WGTP", "YRBLT", "TEN", "RNTP", "HINCP", "ELEP", "ADJINC", "ADJHSG"). I am using R version 4.5.1 and tidycensus version 1.7.3

My code runs when I do not include replicate weights, but fails consistently when I try to retrieve the data with rep_weights = "housing." Is this a server issue with the Census API or is something else wrong? I also asked this question on stack exchange and others were able to replicate this issue. It specifically stops at 53 MB. Thank you, I really appreciate your work!

My code:


fl_housing <- get_pums(
    variables = c("BLD", "WGTP", "YRBLT", "TEN", "RNTP", "HINCP", "ELEP", "ADJINC", "ADJHSG"),  
    state = "FL",
    survey = "acs5",
    recode = TRUE,
    rep_weights = "housing",  
    year = 2023,
    variables_filter = list(SPORDER = 1)
  )  

R error message:


Error in `map()`:
ℹ In index: 1.
ℹ With name: 1.
Caused by error in `curl::curl_fetch_memory()`:
! Failure when receiving data from the peer [api.census.gov]:
Recv failure: Connection was reset
Run `rlang::last_trace()` to see where the error occurred.

> rlang::last_trace()
<error/purrr_error_indexed>
Error in `map()`:
ℹ In index: 1.
ℹ With name: 1.
Caused by error in `curl::curl_fetch_memory()`:
! Failure when receiving data from the peer [api.census.gov]:
Recv failure: Connection was reset
---
Backtrace:
     ▆
  1. ├─tidycensus::get_pums(...)
  2. │ └─purrr::map(...)
  3. │   └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
  4. │     ├─purrr:::with_indexed_errors(...)
  5. │     │ └─base::withCallingHandlers(...)
  6. │     ├─purrr:::call_with_cleanup(...)
  7. │     └─tidycensus (local) .f(.x[[i]], ...)
  8. │       └─tidycensus:::load_data_pums(...)
  9. │         └─httr::GET(base, query = query, httr::progress())
 10. │           └─httr:::request_perform(req, hu$handle$handle)
 11. │             ├─httr:::request_fetch(req$output, req$url, handle)
 12. │             └─httr:::request_fetch.write_memory(req$output, req$url, handle)
 13. │               └─curl::curl_fetch_memory(url, handle = handle)
 14. └─curl:::raise_libcurl_error(...)
 15.   └─base::stop(e)
Run rlang::last_trace(drop = FALSE) to see 3 hidden frames.

ghutton7 avatar Nov 03 '25 02:11 ghutton7

See my Stack Overflow answer, which shows how to avoid this issue. It involves iteratively downloading the weights separately in manageable chunks. As stated in the SO answer, it works for Florida, but some adjustments may be required for states with larger populations.

ltyrone avatar Nov 09 '25 22:11 ltyrone

Hmm. This is something that always worked before. I wonder if this is 1) due to the government shutdown in some capacity, or 2) a new limit imposed server-side.

I would say use the SO answer for now and we'll check again once the government re-opens. If the issue persists after that, I'll check in with Census staff when they are back to work and patch if necessary.

walkerke avatar Nov 11 '25 03:11 walkerke

@walkerke - I re-ran the code and it worked, looks like it was a result of the shutdown. Thanks again.

ltyrone avatar Nov 25 '25 02:11 ltyrone

Confirmed, thanks!

walkerke avatar Nov 26 '25 18:11 walkerke