get_decennial_recs() is an all purpose function to generate decennial estimates (2010 or beyond) for Census Tract, Counties, MSAs, and Census Places in Washington State.

  • Counties will default to King, Kitsap, Pierce, and Snohomish Counties. Otherwise provide a single county or a vector of counties
  • Provide a single table code or a vector of table codes
  • Provide a single FIPS code or a vector of FIPS codes when querying for MSAs or Census Places

Arguments can look like this:

Sys.getenv("CENSUS_API_KEY")
tbl_names <- paste0('PCT020', LETTERS[1:6])
get_decennial_recs(geography = 'county', table_codes = tbl_names, year = 2010)

get_decennial_recs(geography = 'tract', table_codes = tbl_names, year = 2010)

get_decennial_recs(geography = 'msa',
                  table_codes = c("H001", "P001"),
                  year = 2010,
                  fips = c('42660', "28420"))

If we queried for Census Places such as Seattle City and Burien City, results would look like this:

get_decennial_recs(geography = 'place',
                   table_codes = 'PCT013',
                   year = 2010,
                   fips = c("5363000", "5308850"))
#> Warning in attr(x, "align"): 'xfun::attr()' is deprecated.
#> Use 'xfun::attr2()' instead.
#> See help("Deprecated")
#> Warning in attr(x, "format"): 'xfun::attr()' is deprecated.
#> Use 'xfun::attr2()' instead.
#> See help("Deprecated")
GEOID NAME variable value label concept
5308850 Burien city, Washington PCT013001 33013 Total SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS
5363000 Seattle city, Washington PCT013001 583735 Total SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS
5308850 Burien city, Washington PCT013002 16612 Total!!Male SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS
5363000 Seattle city, Washington PCT013002 290243 Total!!Male SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS
5308850 Burien city, Washington PCT013003 1140 Total!!Male!!Under 5 years SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS
5363000 Seattle city, Washington PCT013003 16424 Total!!Male!!Under 5 years SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS
5308850 Burien city, Washington PCT013004 1065 Total!!Male!!5 to 9 years SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS
5363000 Seattle city, Washington PCT013004 12919 Total!!Male!!5 to 9 years SEX BY AGE FOR THE POPULATION IN HOUSEHOLDS