Memvisualisasikan margin galat di ACS

Menganalisis Data Sensus AS di R

Kyle Walker

Instructor

Memvisualisasikan ketidakpastian

  • Pendekatan umum: plot batang galat

Contoh plot batang galat

Menganalisis Data Sensus AS di R

Plot margin galat di ggplot2

  • Di ggplot2: geom_errorbar() dan geom_errorbarh()
library(tidycensus)
library(tidyverse)

wyoming_age <- get_acs(geography = "county", 
                       variables = c(medianage = "B01002_001"), 
                       state = "WY")  

ggplot(wyoming_age, aes(x = estimate, y = NAME)) + 
  geom_errorbarh(aes(xmin = estimate - moe, 
                     xmax = estimate + moe)) + 
  geom_point()
Menganalisis Data Sensus AS di R

plot margin galat tanpa format

Menganalisis Data Sensus AS di R

Memformat plot margin galat

wyoming_age2 <- wyoming_age %>%
  mutate(NAME = str_replace(NAME, " County, Wyoming", ""))

ggplot(wyoming_age2, aes(x = estimate, y = reorder(NAME, estimate))) + geom_errorbarh(aes(xmin = estimate - moe, xmax = estimate + moe)) + geom_point(size = 3, color = "darkgreen") + theme_grey(base_size = 14) + labs(title = "Usia median, county di Wyoming", subtitle = "American Community Survey 2012-2016", x = "Estimasi ACS (batang menunjukkan margin galat)", y = "")
Menganalisis Data Sensus AS di R

plot margin galat terformat

Menganalisis Data Sensus AS di R

Ayo berlatih!

Menganalisis Data Sensus AS di R

Preparing Video For Download...