Get startedGet started for free

Quick visual exploration of ACS margins of error

In Chapter 1, you learned how to create a dot plot of ACS income estimates. In this chapter, you've also learned about the importance of taking margins of error into account in ACS analyses. While margins of error are likely minimal for state-level estimates, they may be more significant for sub-state estimates, like counties. In this exercise, you'll learn how to visualize margins of error around estimates with ggplot2.

This exercise is part of the course

Analyzing US Census Data in R

View Course

Exercise instructions

  • Get a median household income dataset from the ACS for counties in Maine.
  • Use the geom_errorbarh() function in ggplot2 to create horizontal error bars defined by the margin of error around each estimate.
  • Add dots to your ggplot2 chart with geom_point().

Hands-on interactive exercise

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

# Request median household income data
maine_inc <- ___(___ = "county", 
                     variables = c(hhincome = "B19013_001"), 
                     ___ = "ME") 

# Generate horizontal error bars with dots
ggplot(___, aes(x = estimate, y = NAME)) + 
  ___(aes(xmin = estimate - moe, xmax = estimate + moe)) + 
  ___()
Edit and Run Code