racscensus

Call Data Profile (DP) tables in r using acs package


I want to call the Data Profile tables in R using the acs package but I am not sure that it is possible. My code is below. I have used the code to call B tables with no problem. I think the issue is that I am not giving the correct information in the acs.fetch function. The address for DP tables is https://api.census.gov/data/2009/acs/acs5/profile which has the /profile after the /acs5 (which is where it stops for the B tables). Does anyone know how to use the acs package to call the DP tables?

library(acs)

# **Create the set of geographies**
kc_tracts<-geo.make(state="WA",county=c(33), tract="*")

# **Download DP table**
DP02<-acs.fetch(endyear=2009,span=5,geography=kc_tracts,table.number="DP02")

Solution

  • I don't know about the acs library. tidycensus can get DP02 like this:

    sVarNames <- load_variables(2018, "acs5/subject", cache = TRUE)
    pVarNames <- load_variables(2018, "acs5/profile", cache = TRUE)
    otherVarNames <- load_variables(2018, "acs5", cache = TRUE)
    
    head(pVarNames)
    ## # A tibble: 6 x 3
    ##   name     label                         concept                  
    ##   <chr>    <chr>                         <chr>                    
    ## 1 DP02_00… Estimate!!HOUSEHOLDS BY TYPE… SELECTED SOCIAL CHARACTE…
    ## 2 DP02_00… Percent Estimate!!HOUSEHOLDS… SELECTED SOCIAL CHARACTE…
    ## 3 DP02_00… Estimate!!HOUSEHOLDS BY TYPE… SELECTED SOCIAL CHARACTE…
    ## 4 DP02_00… Percent Estimate!!HOUSEHOLDS… SELECTED SOCIAL CHARACTE…
    ## 5 DP02_00… Estimate!!HOUSEHOLDS BY TYPE… SELECTED SOCIAL CHARACTE…
    ## 6 DP02_00… Percent Estimate!!HOUSEHOLDS… SELECTED SOCIAL CHARACTE…
    

    see https://walker-data.com/tidycensus/articles/basic-usage.html

    and https://geodacenter.github.io/opioid-environment-toolkit/getACSData-tutorial.html