Understanding tidycensus options
As discussed in this lesson, Census data comprise thousands of variables available across dozens of geographies! Most of these geography-variable combinations are accessible with tidycensus; however, it helps to understand the package options.
Some data, like Census tracts, are only available by state, and users might want to subset by county; tidycensus facilitates this with state
and county
parameters when appropriate. Additionally, tidycensus includes the Census variable ID in the variable
column; however, a user might want to supply her own variable name, which can be accomplished with a named vector.
You'll be using the Census variable B19013_001
here, which refers to median household income.
This exercise is part of the course
Analyzing US Census Data in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Get an ACS dataset for Census tracts in Texas by setting the state
tx_income <- get_acs(geography = "tract",
variables = "B19013_001",
___ = "TX")
# Inspect the dataset
head(tx_income)