Visualizzare i dati del Census con ggplot2

Analizzare i dati del Censimento USA in R

Kyle Walker

Instructor

ggplot2: una grammatica grafica a livelli in R

Esagono ggplot2

Analizzare i dati del Censimento USA in R

Esempio: reddito per stato

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()
Analizzare i dati del Censimento USA in R

Dot plot non formattato

Analizzare i dati del Censimento USA in R

Personalizzare grafici ggplot2 con dati 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")
Analizzare i dati del Censimento USA in R

Dot plot formattato

Analizzare i dati del Censimento USA in R

Esercitiamoci!

Analizzare i dati del Censimento USA in R

Preparing Video For Download...