MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Analyzing US Census Data in R

Lihat Kursus

Petunjuk latihan

  • 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().

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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 dan Jalankan Kode