1

Problem

I am given a long list of specific variable codes for the DP05 table - in the census bureau format. For instance:

target_dp05_vars = c(perc_white = "HC03_VC53",
    perc_black = "HC03_VC55",
    perc_native = "HC03_VC56")

Since tidycensus uses its own variable naming convention, I can't use the above easily. How do I easily crosswalk to the tidycensus definition?

Temporary solution

In the meantime, I've downloaded the bureau file manually and eliminated rows with HC02 and HC04 prefixes to match with tidycensus to create an internal crosswalk (because it's at least positionally correct) but it's tedious.

I'd love to just feed those HCs as a named vector into get_acs() and perhaps just specify the table as DP05.

Robert Tan
  • 634
  • 1
  • 8
  • 21
  • There are other packages to access the census ... the choice is not just tidycensus or download yourself. If you want ACS data the acs package is very good. – Elin Jan 18 '19 at 04:01
  • While the acs package is very good, I do not believe it supports the ACS Data Profile as the OP requests. – kwalkertcu Jan 19 '19 at 03:31

1 Answers1

2

tidycensus doesn't use its own variable naming convention - it uses variable IDs as specified by the Census API. For example, see https://api.census.gov/data/2017/acs/acs5/profile/variables.html, which is accessible in R with:

library(tidycensus)
dp17 <- load_variables(2017, "acs5/profile", cache = TRUE)

The IDs you've provided appear to be FactFinder codes.

If you want the full DP05 table in one tidycensus call, you can do the following (e.g. for counties in New York) with tidycensus 0.9:

dp05 <- get_acs(geography = "county", 
                table = "DP05", 
                state = "NY")

Mapping of variable IDs to their meanings are in turn available with load_variables().

Note: I am getting intermittent server errors with these calls from the API, which may be due to the government shutdown. If it doesn't work at first, try again.

kwalkertcu
  • 1,011
  • 6
  • 8