get_acs: Obtain data and feature geometry for the five-year American...

Description Usage Arguments Value Examples

View source: R/acs.R

Description

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

Usage

1
2
3
4
get_acs(geography, variables = NULL, table = NULL, cache_table = FALSE,
  year = 2015, endyear = NULL, output = "tidy", state = NULL,
  county = NULL, geometry = FALSE, keep_geo_vars = FALSE,
  summary_var = NULL, key = NULL, moe_level = 90, survey = "acs5", ...)

Arguments

geography

The geography of your data.

variables

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

table

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).

cache_table

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.

year

The year, or endyear, of the ACS sample. 2010 through 2015 are available for five-year data; 2016 is also available for 1-year data. Defaults to 2015.

endyear

Deprecated and will be removed in a future release.

output

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.

state

The state for which you are requesting data. State names, postal codes, and FIPS codes are accepted. Defaults to NULL.

county

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.

geometry

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.

keep_geo_vars

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

summary_var

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.

key

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

moe_level

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

survey

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

Value

A tibble or sf tibble of ACS data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 
library(tidycensus)
library(tidyverse)
library(viridis)
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 = "2011-2015 American Community Survey",
       y = "",
       x = "ACS estimate (bars represent margin of error)")


## End(Not run)

ColoradoDemography/tidycensus documentation built on May 18, 2019, 7:04 p.m.