Description Usage Arguments Value Examples
Obtain data and feature geometry for the decennial Census
1 2 3 4 |
geography |
The geography of your data. |
variables |
Character string or vector of character strings of variable IDs. |
table |
The Census 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 |
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
|
year |
The year for which you are requesting data. 1990, 2000, and 2010 are available. |
sumfile |
The Census summary file. Defaults to sf1; the function will look in sf3 if it cannot find a variable in sf1. |
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, and block group are supported for 1990 through 2010; block and ZCTA geometry are supported for 2000 and 2010. |
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. |
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 decennial Census 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 |
... |
Other keyword arguments |
a tibble or sf tibble of decennial Census data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
# Plot of race/ethnicity by county in Illinois for 2010
library(tidycensus)
library(tidyverse)
library(viridis)
census_api_key("YOUR KEY GOES HERE")
vars10 <- c("P0050003", "P0050004", "P0050006", "P0040003")
il <- get_decennial(geography = "county", variables = vars10, year = 2010,
summary_var = "P0010001", state = "IL", geometry = TRUE) %>%
mutate(pct = 100 * (value / summary_value))
ggplot(il, aes(fill = pct, color = pct)) +
geom_sf() +
facet_wrap(~variable)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.