tidycensus icon indicating copy to clipboard operation
tidycensus copied to clipboard

Unhandled case in `acs_state` when `length(vars_rest)==0`

Open warnes opened this issue 1 year ago • 0 comments

With

> packageVersion('tidycensus')
[1] ‘1.6.7’

executing this code

library(tidycensus)

acs_state <- get_acs(
  geography = "block group", 
  year  = 2022,
  state = 'AL', 
  variables = 
    c(
      median_income = "B19013_001",
      households    = "B11012_001",
      population    = "B01003_001",
      has_computer  = "B28003_002",
      dialup_internet    = "B28003_003",
      broadband_internet = "B28003_004",
      no_internet        = "B28003_005",
      median_percent_of_income_spent_on_rent = "B25071_001",
      poverty = ""
    ), 
  geometry = TRUE,
  keep_geo_vars = FALSE,
  cache_table = TRUE,
  output = "wide"
) 

yields the error:

> library(tidycensus)

> acs_state <- get_acs(
+   geography = "block group", 
+   year  = 2022,
+   state = 'AL', 
+   variables = 
+     c(
+       median_income = "B19013 ..." ... [TRUNCATED] 
Getting data from the 2018-2022 5-year ACS
Fetching data by table type ("B/C", "S", "DP") and combining the result.
Error in `reduce()`:
! Must supply `.init` when `.x` is empty.
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `reduce()`:
! Must supply `.init` when `.x` is empty.
---
Backtrace:
    ▆
 1. ├─base::source("/private/tmp/error.R", echo = TRUE)
 2. │ ├─base::withVisible(eval(ei, envir))
 3. │ └─base::eval(ei, envir)
 4. │   └─base::eval(ei, envir)
 5. ├─tidycensus::get_acs(...) at private/tmp/error.R:3:1
 6. │ └─... %>% reduce(left_join, by = c("GEOID", "NAME"))
 7. └─purrr::reduce(.init = <empty>)
Run rlang::last_trace(drop = FALSE) to see 4 hidden frames.

> packageVersion('tidycensus')
[1] ‘1.6.7’
>  sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-apple-darwin20
Running under: macOS 15.0.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] parallel  stats     graphics  grDevices datasets 
[6] utils     methods   base     

other attached packages:
 [1] fccData_1.2.1    bbcDB_1.1        tidycensus_1.6.7
 [4] sf_1.0-18        tictoc_1.2.1     DBI_1.2.3       
 [7] readr_2.1.5      glue_1.8.0       dplyr_1.1.4     
[10] RPostgres_1.4.7 

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1   blob_1.2.4        
 [3] fastmap_1.2.0      promises_1.3.0    
 [5] digest_0.6.37      timechange_0.3.0  
 [7] mime_0.12          lifecycle_1.0.4   
 [9] ellipsis_0.3.2     magrittr_2.0.3    
[11] compiler_4.4.1     rlang_1.1.4       
[13] tools_4.4.1        utf8_1.2.4        
[15] yaml_2.3.10        knitr_1.48        
[17] htmlwidgets_1.6.4  bit_4.5.0         
[19] pkgbuild_1.4.4     classInt_0.4-10   
[21] curl_5.2.3         xml2_1.3.6        
[23] pkgload_1.4.0      KernSmooth_2.23-24
[25] miniUI_0.1.1.1     withr_3.0.1       
[27] purrr_1.0.2        sys_3.4.3         
[29] desc_1.4.3         grid_4.4.1        
[31] fansi_1.0.6        urlchecker_1.0.1  
[33] profvis_0.4.0      xtable_1.8-4      
[35] e1071_1.7-16       cli_3.6.3         
[37] rmarkdown_2.28     crayon_1.5.3      
[39] generics_0.1.3     remotes_2.5.0     
[41] rstudioapi_0.17.1  httr_1.4.7        
[43] tzdb_0.4.0         sessioninfo_1.2.2 
[45] cachem_1.1.0       proxy_0.4-27      
[47] stringr_1.5.1      rvest_1.0.4       
[49] vctrs_0.6.5        tigris_2.1        
[51] devtools_2.4.5     V8_6.0.0          
[53] jsonlite_1.8.9     geojsonsf_2.0.3   
[55] hms_1.1.3          bit64_4.5.2       
[57] h3_3.7.2           tidyr_1.3.1       
[59] units_0.8-5        lubridate_1.9.3   
[61] stringi_1.8.4      later_1.3.2       
[63] tibble_3.2.1       pillar_1.9.0      
[65] rappdirs_0.3.3     htmltools_0.5.8.1 
[67] R6_2.5.1           dbplyr_2.5.0      
[69] rprojroot_2.0.4    evaluate_1.0.1    
[71] shiny_1.9.1        RMariaDB_1.3.2    
[73] memoise_2.0.1      renv_1.0.11       
[75] httpuv_1.6.15      class_7.3-22      
[77] Rcpp_1.0.13        uuid_1.2-1        
[79] h3jsr_1.3.1        xfun_0.48         
[81] fs_1.6.4           usethis_3.0.0     
[83] pkgconfig_2.0.3  

warnes avatar Oct 26 '24 00:10 warnes