Census-gegevens visualiseren met ggplot2

US Census-gegevens analyseren in R

Kyle Walker

Instructor

ggplot2: een gelaagde grafische grammatica in R

ggplot2-hex

US Census-gegevens analyseren in R

Voorbeeld: inkomen per staat plotten

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()
US Census-gegevens analyseren in R

Ongeformatteerde dotplot

US Census-gegevens analyseren in R

ggplot2-grafieken van ACS-gegevens aanpassen

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")
US Census-gegevens analyseren in R

Geformatteerde dotplot

US Census-gegevens analyseren in R

Laten we oefenen!

US Census-gegevens analyseren in R

Preparing Video For Download...