Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show_call not working for small geographies in get_acs() #485

Open
aarondd opened this issue Nov 16, 2022 · 1 comment
Open

show_call not working for small geographies in get_acs() #485

aarondd opened this issue Nov 16, 2022 · 1 comment

Comments

@aarondd
Copy link

aarondd commented Nov 16, 2022

Hi there,

First of all, I can't stop raving about this package. What a contribution to the research community!

I noticed that the show_call flag in get_acs() is not working as expected for "tract" and "block group" settings. It doesn't return the unified API call that I'd expect. Here's an example:

get_acs(
  geography = "tract",
  variables = c(total_population = "B01001_001",
                total_poverty_status = "B17001_001"),
  year = 2020,
  state = c("OH", "NY"),
  survey = "acs5",
  show_call = TRUE)

What I'd expect:

Getting data from the 2016-2020 5-year ACS
Fetching tract data by state and combining the result.
Census API call: https://api.census.gov/data/2020/acs/acs5?get=B01001_001E%2CB01001_001M%2CB17001_001E%2CB17001_001M%2CNAME&for=tract%3A%2A&in=state%3A39%2C36
# A tibble: 17,158 × 5
   GEOID       NAME                                     variable             estimate   moe
   <chr>       <chr>                                    <chr>                   <dbl> <dbl>
 1 39001770100 Census Tract 7701, Adams County, Ohio    total_population         4498   444
 2 39001770100 Census Tract 7701, Adams County, Ohio    total_poverty_status     4498   444
 3 39001770200 Census Tract 7702, Adams County, Ohio    total_population         4786   481
 4 39001770200 Census Tract 7702, Adams County, Ohio    total_poverty_status     4669   455
 5 39001770301 Census Tract 7703.01, Adams County, Ohio total_population         3781   683
 6 39001770301 Census Tract 7703.01, Adams County, Ohio total_poverty_status     3781   683
 7 39001770302 Census Tract 7703.02, Adams County, Ohio total_population         3385   557
 8 39001770302 Census Tract 7703.02, Adams County, Ohio total_poverty_status     3385   557
 9 39001770400 Census Tract 7704, Adams County, Ohio    total_population         4528   432
10 39001770400 Census Tract 7704, Adams County, Ohio    total_poverty_status     4240   447
# … with 17,148 more rows

Instead, it doesn't show any call:

Getting data from the 2016-2020 5-year ACS
Fetching tract data by state and combining the result.
# A tibble: 17,158 × 5
   GEOID       NAME                                     variable             estimate   moe
   <chr>       <chr>                                    <chr>                   <dbl> <dbl>
 1 39001770100 Census Tract 7701, Adams County, Ohio    total_population         4498   444
 2 39001770100 Census Tract 7701, Adams County, Ohio    total_poverty_status     4498   444
 3 39001770200 Census Tract 7702, Adams County, Ohio    total_population         4786   481
 4 39001770200 Census Tract 7702, Adams County, Ohio    total_poverty_status     4669   455
 5 39001770301 Census Tract 7703.01, Adams County, Ohio total_population         3781   683
 6 39001770301 Census Tract 7703.01, Adams County, Ohio total_poverty_status     3781   683
 7 39001770302 Census Tract 7703.02, Adams County, Ohio total_population         3385   557
 8 39001770302 Census Tract 7703.02, Adams County, Ohio total_poverty_status     3385   557
 9 39001770400 Census Tract 7704, Adams County, Ohio    total_population         4528   432
10 39001770400 Census Tract 7704, Adams County, Ohio    total_poverty_status     4240   447
# … with 17,148 more rows

I assume that the state-wise split for small geographies is for efficiency, since the Census API can handle a multi-state call by tract or block group? If so, I'd expect the unified API call (succinct, for documentation purposes) rather than the API call for each state individually (what's actually called).

@walkerke
Copy link
Owner

walkerke commented Dec 2, 2022

Thank you for the kind words @aarondd!

You have diagnosed this correctly - originally multi-state small geography calls weren't possible in the API, but that has since changed and we don't use that feature. Instead we iterate through the states and make multiple calls.

I'm going to give some thought to this. It's possible that we make the switch internally to use the new multi-state functionality in the API; I want to do some performance tests. If we make that switch, this issue will resolve itself as the correct URL will be returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants