A thin wrapper around tidycensus::get_acs() that hard-codes New York
City geographies, never downloads geometry, and returns a tidy tibble
keyed by geoid (lowercased) with a county column (borough name) ready
for joining to the spatial objects in the nycmaps package.
Arguments
- variables
A character vector (optionally named) of Census variable IDs. See
load_nyc_variables()ortidycensus::load_variables().- year
ACS endyear. If
NULL(the default), uses thetidycensus::get_acs()default, which is the most recent vintage thattidycensussupports.- geography
Geographic level. One of
"tract"(default),"block group","county", or"puma". For"tract","block group", and"county"the request is restricted to the five NYC counties viatidycensus'scountyargument. For"puma",tidycensusdoes not accept acountyfilter, so all NY state PUMAs are requested and then filtered down to the 55 NYC PUMAs using an internal crosswalk. The crosswalk vintage is chosen fromyear: ACS endyears up to and including 2021 use the 2010 PUMA vintage, 2022 and later use the 2020 vintage. Seenyc_pumas().- survey
ACS sample, passed to
tidycensus::get_acs(). Defaults to"acs5".- summary_var
Optional summary (denominator) variable.
- output
"wide"(the default) or"tidy". When"wide", thevariablecolumn is pivoted out so each variable becomes its own column.- ...
Additional arguments forwarded to
tidycensus::get_acs().
Value
A tibble with geoid and county as the first two columns,
followed by the requested variables. The ACS endyear actually used is
stored in the "acs_year" attribute.
Examples
if (FALSE) { # \dontrun{
# Median household income, latest 5-year ACS, NYC tracts.
get_nyc_acs(c(med_hhinc = "B19013_001"))
# Same, but at the PUMA level.
get_nyc_acs(
c(med_hhinc = "B19013_001"),
geography = "puma"
)
# Same, but one row per borough.
get_nyc_acs(
c(med_hhinc = "B19013_001"),
geography = "county"
)
# Race and Hispanic origin, with total population as the denominator.
race_vars <- c(
nh_white = "B03002_003",
nh_black = "B03002_004",
nh_asian = "B03002_006",
hispanic = "B03002_012"
)
get_nyc_acs(race_vars, summary_var = "B03002_001")
} # }