การแสดงผล margin of error ใน ACS

การวิเคราะห์ข้อมูลสำมะโนประชากรสหรัฐฯ ใน R

Kyle Walker

Instructor

การแสดงความไม่แน่นอน

  • วิธีที่นิยมใช้: error bar plot

ตัวอย่าง error bar plot

การวิเคราะห์ข้อมูลสำมะโนประชากรสหรัฐฯ ใน R

กราฟ margin of error ใน ggplot2

  • ใน ggplot2: geom_errorbar() และ 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()
การวิเคราะห์ข้อมูลสำมะโนประชากรสหรัฐฯ ใน R

กราฟ margin of error ที่ยังไม่ได้จัดรูปแบบ

การวิเคราะห์ข้อมูลสำมะโนประชากรสหรัฐฯ ใน R

การจัดรูปแบบกราฟ margin of error

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 = "Median age, counties in Wyoming", subtitle = "2012-2016 American Community Survey", x = "ACS estimate (bars represent margins of error)", y = "")
การวิเคราะห์ข้อมูลสำมะโนประชากรสหรัฐฯ ใน R

กราฟ margin of error ที่จัดรูปแบบแล้ว

การวิเคราะห์ข้อมูลสำมะโนประชากรสหรัฐฯ ใน R

มาฝึกกันเถอะ!

การวิเคราะห์ข้อมูลสำมะโนประชากรสหรัฐฯ ใน R

Preparing Video For Download...