Memetakan data demografi dengan ggplot2

Menganalisis Data Sensus AS di R

Kyle Walker

Instructor

Peta koroplet dasar dengan geom_sf()

library(ggplot2)

ggplot(cook_value, aes(fill = estimate)) + 
  geom_sf()
Menganalisis Data Sensus AS di R

plot ggplot Cook County pertama

Menganalisis Data Sensus AS di R

Mengubah warna peta

ggplot(cook_value, aes(fill = estimate, color = estimate)) + 
  geom_sf() + 
  scale_fill_viridis_c() +  
  scale_color_viridis_c()

plot Cook County dengan viridis

Menganalisis Data Sensus AS di R

Menyesuaikan keluaran peta

ggplot(cook_value, aes(fill = estimate, color = estimate)) + 
  geom_sf() + 
  scale_fill_viridis_c(labels = scales::dollar) +  
  scale_color_viridis_c(guide = FALSE) + 
  theme_minimal() + 
  coord_sf(crs = 26916, datum = NA) + 
  labs(title = "Median home value by Census tract", 
       subtitle = "Cook County, Illinois", 
       caption = "Data source: 2012-2016 ACS.\nData acquired with the R 
                  tidycensus package.", 
       fill = "ACS estimate")
Menganalisis Data Sensus AS di R

ggplot Cook County yang diformat

Menganalisis Data Sensus AS di R

Ayo berlatih!

Menganalisis Data Sensus AS di R

Preparing Video For Download...