walkerke / tidycensus

Load US Census boundary and attribute data as 'tidyverse' and 'sf'-ready data frames in R
https://walker-data.com/tidycensus
Other
639 stars 100 forks source link

tidycensus::get_decennial returns error when trying to get P5 redistricting data table #406

Closed kmcd39 closed 3 years ago

kmcd39 commented 3 years ago

I'm trying to get the supplemental P.L. 94-171 Redistricting data from the 2020 decennial census (https://www.census.gov/programs-surveys/decennial-census/about/rdo/summary-files.html) But I'm getting an error.

I.e., with the call: gq <- tidycensus::get_decennial(geography = 'tract' ,table = 'P5' ,year = 2020 , geometry = F ,cache_table = TRUE ,state = 42) I get the messages and then the error: Getting data from the 2020 decennial Census Using the PL 94-171 Redistricting Data summary file Error in UseMethod("gather") : no applicable method for 'gather' applied to an object of class "character"

Maybe there is a mistake in my call--I've been using tidycensus with acs for a while but am new to using it for the census---but flagging the issue here. I have been able to get the tables required through NHGIS.

Thank you so much for the amazing packages!

walkerke commented 3 years ago

This is a bug - thanks, good catch! Re-install from GitHub and it should work:

gq <- tidycensus::get_decennial(
    geography = 'tract',
    table = 'P5',
    year = 2020,
    geometry = F,
    cache_table = TRUE,
    state = 42
  )

gq
# A tibble: 34,460 × 4
   GEOID       NAME                                                    variable value
   <chr>       <chr>                                                   <chr>    <dbl>
 1 42129808500 Census Tract 8085, Westmoreland County, Pennsylvania    P5_001N      0
 2 42129808300 Census Tract 8083, Westmoreland County, Pennsylvania    P5_001N     42
 3 42129808401 Census Tract 8084.01, Westmoreland County, Pennsylvania P5_001N      0
 4 42129808402 Census Tract 8084.02, Westmoreland County, Pennsylvania P5_001N     83
 5 42129808600 Census Tract 8086, Westmoreland County, Pennsylvania    P5_001N      2
 6 42131400100 Census Tract 4001, Wyoming County, Pennsylvania         P5_001N      0
 7 42131400200 Census Tract 4002, Wyoming County, Pennsylvania         P5_001N      0
 8 42131400300 Census Tract 4003, Wyoming County, Pennsylvania         P5_001N    386
 9 42131400400 Census Tract 4004, Wyoming County, Pennsylvania         P5_001N    108
10 42131400500 Census Tract 4005, Wyoming County, Pennsylvania         P5_001N      6
# … with 34,450 more rows 
kmcd39 commented 3 years ago

Amazing -- thank you!