library(swimr, warn.conflicts = FALSE) library(knitr) library(dplyr) library(ggplot2) opts_chunk$set( echo = FALSE, message = FALSE, warning = FALSE, fig.keep = TRUE, fig.path = params$fig.path, fig.width=8, fig.height=6 )
ref <- dbConnect(SQLite(), dbname=params$ref_db) # reference db1 <- dbConnect(SQLite(), dbname=params$current_db) # current db3 <- dbConnect(SQLite(), dbname=params$compare_db) # current dbset <- list(ref, db1, db3) db_names <- c( params$ref_name, params$current_name, params$compare_name )
zones_shp <- extract_zones(db = ref) zones_data <- zones_shp@data zones <- fortify(zones_shp) %>% left_join(zones_data, by='id')
In this report we group figures by ODOT regions.^[As a note, ODOT's region definitions divide counties (and TLUMIP model zones). These are approximate definitions that keep counties in a single region.]
ggplot(zones, aes(x = long, y = lat, fill = factor(DOT_REGION), group = group)) + geom_polygon() + coord_map("conic", lat0 = 43)
regions = zones_data$DOT_REGION %>% unique() %>% sort() for(r in regions){ counties <- zones_data %>% filter(DOT_REGION == r) p <- multiple_sevar(dbset, db_names, variable = "population", facet_var = "COUNTY", facet_levels = unique(counties$COUNTY)) + ggtitle(paste("Region", r)) + theme(legend.position = "bottom") print(p) if(r < 6){ p <- plot_history(ref, counties = counties$COUNTY) + ggtitle(paste("Historical Region (Reference)", r)) print(p) } }
for(r in regions){ counties <- zones_data %>% filter(DOT_REGION == r) p <- multiple_sevar(dbset, db_names, variable = "employment", facet_var = "COUNTY", facet_levels = counties$COUNTY) print(p + ggtitle(paste("Region", r)) + theme(legend.position = "bottom")) }
for(r in regions){ counties <- zones_data %>% filter(DOT_REGION == r) p <- multiple_employment(dbset, db_names, facet_var = "COUNTY", facet_levels = counties$COUNTY) print(p + ggtitle(paste("Region", r)) + theme(legend.position = "bottom")) }
for(r in regions){ counties <- zones_data %>% filter(DOT_REGION == r) p <- multiple_wapr(dbset, db_names, facet_var = "COUNTY", facet_levels = counties$COUNTY) print(p + ggtitle(paste("Region", r)) + theme(legend.position = "bottom")) }
for(r in regions){ counties <- zones_data %>% filter(DOT_REGION == r) p <- multiple_floorspace(dbset = dbset, db_names = db_names, variable = 'floorspace', facet_var = "COUNTY", facet_levels = counties$COUNTY) print(p + ggtitle(paste("Region", r)) + theme(legend.position = "bottom")) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.