knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(mycensus)
Sys.getenv("CENSUS_API_KEY")
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.
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"))
df <- get_decennial_recs(geography = 'place', table_codes = 'PCT013', year = 2010, fips = c("5363000", "5308850")) knitr::kable(head(df, 8))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.