การแสดงผลข้อมูลสำมะโนด้วย ggplot2

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

Kyle Walker

Instructor

ggplot2: ไวยากรณ์กราฟิกแบบเลเยอร์ใน R

ggplot2 hex

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

ตัวอย่าง: พล็อตรายได้แยกตามรัฐ

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

Dot plot ที่ยังไม่ได้จัดรูปแบบ

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

ปรับแต่งกราฟ ggplot2 จากข้อมูล ACS

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

Dot plot ที่จัดรูปแบบแล้ว

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

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

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

Preparing Video For Download...