Obtain data and feature geometry for the five-year American Community Survey

get_acs(geography, variables = NULL, table = NULL,
  cache_table = FALSE, year = 2017, endyear = NULL,
  output = "tidy", state = NULL, county = NULL, geometry = FALSE,
  keep_geo_vars = FALSE, shift_geo = FALSE, summary_var = NULL,
  key = NULL, moe_level = 90, survey = "acs5", ...)



The geography of your data.


Character string or vector of character strings of variable IDs. tidycensus automatically returns the estimate and the margin of error associated with the variable.


The ACS table for which you would like to request all variables. Uses lookup tables to identify the variables; performs faster when variable table already exists through load_variables(cache = TRUE).


Whether or not to cache table names for faster future access. Defaults to FALSE; if TRUE, only needs to be called once per dataset. If variables dataset is already cached via the load_variables function, this can be bypassed.


The year, or endyear, of the ACS sample. 2010 through 2017 are available. Defaults to 2017.


Deprecated and will be removed in a future release.


One of "tidy" (the default) in which each row represents an enumeration unit-variable combination, or "wide" in which each row represents an enumeration unit and the variables are in the columns.


An optional vector of states for which you are requesting data. State names, postal codes, and FIPS codes are accepted. Defaults to NULL.


The county for which you are requesting data. County names and FIPS codes are accepted. Must be combined with a value supplied to `state`. Defaults to NULL.


if FALSE (the default), return a regular tibble of ACS data. if TRUE, uses the tigris package to return an sf tibble with simple feature geometry in the `geometry` column. state, county, tract, block group, block, and ZCTA geometry are supported.


if TRUE, keeps all the variables from the Census shapefile obtained by tigris. Defaults to FALSE.


if TRUE, returns geometry with Alaska and Hawaii shifted for thematic mapping of the entire US. Geometry was originally obtained from the albersusa R package.


Character string of a "summary variable" from the ACS to be included in your output. Usually a variable (e.g. total population) that you'll want to use as a denominator or comparison.


Your Census API key. Obtain one at http://api.census.gov/data/key_signup.html


The confidence level of the returned margin of error. One of 90 (the default), 95, or 99.


The ACS contains one-year, three-year, and five-year surveys expressed as "acs1", "acs3", and "acs5". The default selection is "acs5."


Other keyword arguments


A tibble or sf tibble of ACS data


census_api_key("YOUR KEY GOES HERE")

tarr <- get_acs(geography = "tract", variables = "B19013_001",
                state = "TX", county = "Tarrant", geometry = TRUE)

ggplot(tarr, aes(fill = estimate, color = estimate)) +
  geom_sf() +
  coord_sf(crs = 26914) +
  scale_fill_viridis(option = "magma") +
  scale_color_viridis(options = "magma")

vt <- get_acs(geography = "county", variables = "B19013_001", state = "VT")

vt %>%
mutate(NAME = gsub(" County, Vermont", "", NAME)) %>%
 ggplot(aes(x = estimate, y = reorder(NAME, estimate))) +
  geom_errorbarh(aes(xmin = estimate - moe, xmax = estimate + moe)) +
  geom_point(color = "red", size = 3) +
  labs(title = "Household income by county in Vermont",
       subtitle = "2012-2016 American Community Survey",
       y = "",
       x = "ACS estimate (bars represent margin of error)")

# }