Generate decennial estimates for multiple tables by multiple tracts and/or counties

get_decennial_tract_county(
  geography,
  counties = c("King", "Kitsap", "Pierce", "Snohomish"),
  table_codes,
  year,
  state = "WA"
)

Arguments

geography

A character string as either 'tract', 'county', 'msa', or 'place'.

counties

A character string or vector of counties. Defaults to PSRC counties.

table_codes

A character string or vector of Census table codes.

year

Numeric value. A decennial year equal or greater than 2010

state

A character string state abbreviation

Value

a tibble of decennial estimates by either tracts in a county/counties for selected table codes. Does not include variable names.

Author

Christy Lam

Examples

Sys.getenv("CENSUS_API_KEY")
#> [1] "325779a5606507b511316d1ecd4328aa21cfc70d"
tbl_names <- paste0('PCT020', LETTERS[1:6])

get_decennial_tract_county(geography = 'county', table_codes = tbl_names, year = 2010)
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020B. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020B. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020B. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020B. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020C. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020C. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020C. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020C. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020D. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020D. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020D. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020D. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020E. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020E. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020E. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020E. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020F. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020F. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020F. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020F. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> # A tibble: 768 × 4
#>    GEOID NAME                    variable   value
#>    <chr> <chr>                   <chr>      <dbl>
#>  1 53033 King County, Washington PCT020A001 24629
#>  2 53033 King County, Washington PCT020A002  7394
#>  3 53033 King County, Washington PCT020A003  1977
#>  4 53033 King County, Washington PCT020A004   392
#>  5 53033 King County, Washington PCT020A005     0
#>  6 53033 King County, Washington PCT020A006     0
#>  7 53033 King County, Washington PCT020A007  1287
#>  8 53033 King County, Washington PCT020A008   298
#>  9 53033 King County, Washington PCT020A009     0
#> 10 53033 King County, Washington PCT020A010   251
#> # ℹ 758 more rows

get_decennial_tract_county(geography = 'county',
                           counties = c('King'),
                           table_codes = tbl_names[1],
                           year = 2010)
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> # A tibble: 32 × 4
#>    GEOID NAME                    variable   value
#>    <chr> <chr>                   <chr>      <dbl>
#>  1 53033 King County, Washington PCT020A001 24629
#>  2 53033 King County, Washington PCT020A002  7394
#>  3 53033 King County, Washington PCT020A003  1977
#>  4 53033 King County, Washington PCT020A004   392
#>  5 53033 King County, Washington PCT020A005     0
#>  6 53033 King County, Washington PCT020A006     0
#>  7 53033 King County, Washington PCT020A007  1287
#>  8 53033 King County, Washington PCT020A008   298
#>  9 53033 King County, Washington PCT020A009     0
#> 10 53033 King County, Washington PCT020A010   251
#> # ℹ 22 more rows

get_decennial_tract_county(geography = 'tract',
                           counties = c('Kitsap', 'Pierce'),
                           table_codes = tbl_names,
                           year = 2010)
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020B. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020B. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020C. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020C. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020D. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020D. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020E. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020E. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020F. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020F. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> # A tibble: 43,584 × 4
#>    GEOID       NAME                                           variable   value
#>    <chr>       <chr>                                          <chr>      <dbl>
#>  1 53035080101 Census Tract 801.01, Kitsap County, Washington PCT020A001    38
#>  2 53035080102 Census Tract 801.02, Kitsap County, Washington PCT020A001   122
#>  3 53035080200 Census Tract 802, Kitsap County, Washington    PCT020A001    41
#>  4 53035080300 Census Tract 803, Kitsap County, Washington    PCT020A001    90
#>  5 53035080400 Census Tract 804, Kitsap County, Washington    PCT020A001     2
#>  6 53035080500 Census Tract 805, Kitsap County, Washington    PCT020A001   117
#>  7 53035080600 Census Tract 806, Kitsap County, Washington    PCT020A001    26
#>  8 53035080700 Census Tract 807, Kitsap County, Washington    PCT020A001    14
#>  9 53035080800 Census Tract 808, Kitsap County, Washington    PCT020A001    57
#> 10 53035080900 Census Tract 809, Kitsap County, Washington    PCT020A001    18
#> # ℹ 43,574 more rows

get_decennial_tract_county(geography = 'tract',
                           counties = c('King'),
                           table_codes = tbl_names[1],
                           year = 2010)
#> Getting data from the 2010 decennial Census
#> Loading SF1 variables for 2010 from table PCT020A. To cache this dataset for faster access to Census tables in the future, run this function with `cache_table = TRUE`. You only need to do this once per Census dataset.
#> Using Census Summary File 1
#> # A tibble: 12,736 × 4
#>    GEOID       NAME                                       variable   value
#>    <chr>       <chr>                                      <chr>      <dbl>
#>  1 53033000100 Census Tract 1, King County, Washington    PCT020A001    32
#>  2 53033000200 Census Tract 2, King County, Washington    PCT020A001    55
#>  3 53033000300 Census Tract 3, King County, Washington    PCT020A001     8
#>  4 53033000401 Census Tract 4.01, King County, Washington PCT020A001    97
#>  5 53033000402 Census Tract 4.02, King County, Washington PCT020A001   247
#>  6 53033000500 Census Tract 5, King County, Washington    PCT020A001    17
#>  7 53033000600 Census Tract 6, King County, Washington    PCT020A001    34
#>  8 53033000700 Census Tract 7, King County, Washington    PCT020A001     9
#>  9 53033000800 Census Tract 8, King County, Washington    PCT020A001    52
#> 10 53033000900 Census Tract 9, King County, Washington    PCT020A001    13
#> # ℹ 12,726 more rows