Visualizing Census data with ggplot2

Analyzing US Census Data in R

Kyle Walker

Instructor

ggplot2: a layered grammar of graphics in R

ggplot2 hex

Analyzing US Census Data in R

Example: plotting income by state

library(tidycensus)
library(tidyverse)

ne_income <- get_acs(geography = "state", 
                     variables = "B19013_001", 
                     survey = "acs1", 
                     state = c("ME", "NH", "VT", "MA", 
                               "RI", "CT", "NY"))

ggplot(ne_income, aes(x = estimate, y = NAME)) + geom_point()
Analyzing US Census Data in R

Unformatted dot plot

Analyzing US Census Data in R

Customizing ggplot2 graphics of ACS data

ggplot(ne_income, 
       aes(x = estimate, 
           y = reorder(NAME, estimate))) + 
  geom_point(color = "navy", size = 4) +

scale_x_continuous(labels = scales::dollar) +
theme_minimal(base_size = 14) +
labs(x = "2016 ACS estimate", y = "", title = "Median household income by state")
Analyzing US Census Data in R

Formatted dot plot

Analyzing US Census Data in R

Let's practice!

Analyzing US Census Data in R

Preparing Video For Download...