Home > Mobile >  Please help me fix an error in tidycensus. Error: Your API call has errors
Please help me fix an error in tidycensus. Error: Your API call has errors

Time:01-25

I am trying to extract some information on occupation from American Community Survey (ACS). But I am getting an error. Can someone please help me understand the error and fix it.

Thanks

Error -

Getting data from the 2016-2020 5-year ACS
Loading ACS5 variables for 2020 from table B24010 and caching the dataset for faster future access.
Using FIPS code '06' for state 'CA'
No encoding supplied: defaulting to UTF-8.
Error: Your API call has errors.  The API message returned is .

Code -

library(tidyverse)
library(tidycensus)

occupation <- get_acs(
    geography = "tract", 
    table = "B24010",
    # summary_var = "B24010_001",
    state = "CA", 
    year = 2020,
    geometry = TRUE,
    cache_table = TRUE)

CodePudding user response:

I think the issue is that the table B24010 is not available via the Census API for that year.

This error and the cause is discussed in a Github issue.

Get the 2020 variables (5 year):

library(tidyverse)
library(tidycensus)

census_vars <- load_variables(2020, "acs5", cache = TRUE)

Do they include B24010? No they don't.

census_vars %>% 
  filter(str_detect(name, "B24010"))

# A tibble: 0 × 4
  • Related