Joining data from tigris and tidycensus

Geometry is currently supported in tidycensus for geographies in the core Census hierarchy - state, county, Census tract, block group, and block - as well as zip code tabulation areas. However, you may be interested in mapping data for other geographies. In this case, you can download the equivalent boundary file from the Census Bureau using the tigris package and join your demographic data to it for mapping.

This exercise is part of the course

Analyzing US Census Data in R

View Course

Exercise instructions

  • Get median household income by unified school district in Idaho by using the geography identifier "school district (unified)".
  • Get unified school district boundaries in Idaho using the school_districts() function.
  • Join the two datasets together with left_join().

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Get an income dataset for Idaho by school district
idaho_income <- ___(___ = ___, 
                        variables = "B19013_001", 
                        ___ = "ID")

# Get a school district dataset for Idaho
idaho_school <- ___(state = "ID", type = "unified", class = "sf")

# Join the income dataset to the boundaries dataset
id_school_joined <- ___(idaho_school, ___, ___ = "GEOID")

plot(id_school_joined["estimate"])