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

Demographic Profile Tables #463

Closed fronberg closed 1 year ago

fronberg commented 2 years ago

I am using tidycensus to access the Census API, but haven't been able to pull variables from the 2000 decennial census demographic profile table (sf3profile). I know that the API has these variables (https://api.census.gov/data/2000/dec/sf3profile/variables.html). Could this be implemented for tidycensus?

walkerke commented 2 years ago

This now works in the GitHub version. Make sure to specify year = 2000 and sumfile = 'sf3profile' for it to work.

library(tidycensus)

get_decennial(
  geography = "tract",
  variables = "DP2_C29",
  state = "TX",
  county = "Tarrant",
  year = 2000,
  sumfile = "sf3profile"
)
#> Getting data from the 2000 decennial Census
#> # A tibble: 310 × 4
#>    GEOID       NAME                                        variable value
#>    <chr>       <chr>                                       <chr>    <dbl>
#>  1 48439100101 Census Tract 1001.01, Tarrant County, Texas DP2_C29    8.5
#>  2 48439100102 Census Tract 1001.02, Tarrant County, Texas DP2_C29   16.6
#>  3 48439100201 Census Tract 1002.01, Tarrant County, Texas DP2_C29    3.9
#>  4 48439100202 Census Tract 1002.02, Tarrant County, Texas DP2_C29    1.2
#>  5 48439100300 Census Tract 1003, Tarrant County, Texas    DP2_C29    3.4
#>  6 48439100400 Census Tract 1004, Tarrant County, Texas    DP2_C29    3.5
#>  7 48439100501 Census Tract 1005.01, Tarrant County, Texas DP2_C29    3.8
#>  8 48439100502 Census Tract 1005.02, Tarrant County, Texas DP2_C29    6.1
#>  9 48439100601 Census Tract 1006.01, Tarrant County, Texas DP2_C29   12.9
#> 10 48439100602 Census Tract 1006.02, Tarrant County, Texas DP2_C29    9.5
#> # … with 300 more rows

Created on 2022-07-14 by the reprex package (v2.0.1)

I'm keeping the issue open because:

walkerke commented 2 years ago

As an aside, this also works out of the box with geometry = TRUE for mapping:

image