Hafen Consulting, LLC
@hafenstats
Ryan Hafen
> state_unemp # A tibble: 867 x 3 year rate state <int> <dbl> <chr> 1 2000 4.6 AL 2 2001 6 AL 3 2002 5.8 AL 4 2003 6 AL 5 2004 5.2 AL 6 2005 4.2 AL 7 2006 3.9 AL 8 2007 4.4 AL 9 2008 8.3 AL 10 2009 11.8 AL # … with 857 more rows
How does unemployment vary geographically and over time?
US annual unemployment rates by state from 2000 to 2016
ggplot(state_unemp, aes(year, rate)) + geom_line() + facet_wrap(~ state)
install.packages("geofacet")
library(geofacet)
This is very easy to do with geofacet
+
ggplot(state_unemp, aes(year, rate)) + geom_line() + facet_geo(~ state, grid = "us_state_grid1")
install.packages("USAboundaries") # get Washington county boundaries from USAboundaries package counties <- USAboundaries::us_counties(states = "washington") # convert to SpatialPolygonsDataFrame counties <- as(counties, "Spatial") # remove unneeded columns counties@data <- counties@data[, c("countyfp", "name")] # this gives counties good initial approximation grd <- grid_auto(counties, seed = 1234)
grid_preview(grd, label = "name_name")
grid_design(grd, label = "name")
(I need some help)