Skip to contents

Download population data for Kansas City from the decennial census or the American Community Survey (ACS). Summary levels are place, county, census tract, census block group, census block (decennial census only), and ZIP code tabulation area (ZCTA). Data sets are downloaded from the US Census Bureau using the tidycensus package.

Usage

get_kc_pop(
  dataset,
  geo = c("place", "county", "tract", "block group", "block", "zcta"),
  year,
  vars,
  var_match = c("fixed", "regex"),
  geoid = NULL,
  ...
)

Arguments

dataset

The data set to download. Passed to the dataset argument in tidycensus::load_variables() and either survey in tidycensus::get_acs() or sumfile in tidycensus::get_decennial().

geo

The geography (summary level) of the data set to download.

year

The year of the data set to download.

vars

A vector of variable names or a regular expression to match variable names for download.

var_match

The type of matching to perform on variable names. "fixed" matches the values in vars exactly, and "regex" matches to a regular expression pattern in vars.

geoid

An optional vector of GEOIDs to supply if the relevant spatial data sets are unavailable in kcData.

...

Additional arguments passed to tidycensus::get_acs() or tidycensus::get_decennial().

Value

A dataframe.

Details

Data sets for geographies other than "place" are filtered for geographic units that intersect with Kansas City. These geographic units are determined by the shapefile downloaded for the specified year. If no shapefile has been downloaded for that year, an error is returned.

Examples

if (FALSE) { # \dontrun{
acs5_2023 <- get_kc_pop(
  dataset = "acs5",
  geo = "place",
  year = 2023,
  vars = "^B01",
  var_match = "regex"
)

dec_2020 <- get_kc_pop(
  dataset = "dhc",
  geo = "block",
  year = 2020,
  vars = "P12_001N",
  var_match = "fixed"
)
} # }