diff --git a/Makefile b/Makefile index 778163a..177883c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ +all: osrm TOPS_data_process crashmaps + osrm: osrm-data osrm-containers +crashmaps: schoolmaps_PDFs crashmaps_dynamic crashmaps_dynamic_milwaukee crash_data_summaries + TOPS_data_process: R/TOPS_data_process.Rmd R -e 'library("rmarkdown"); old_path <- Sys.getenv("PATH"); Sys.setenv(PATH = paste(old_path, "/usr/local/bin", sep = ":")); rmarkdown::render(knit_root_dir = "../", output_dir = "./html", input = "./R/TOPS_data_process.Rmd", output_file = "./html/TOPS_data_process.html")' diff --git a/R/schoolmaps_PDFs.Rmd b/R/schoolmaps_PDFs.Rmd index 0b64953..1a55c7f 100644 --- a/R/schoolmaps_PDFs.Rmd +++ b/R/schoolmaps_PDFs.Rmd @@ -118,16 +118,16 @@ if(str_to_lower(county_focus) == "all") { # set which school types to generate figures for school_type_focus <- run_parameters$school_type_focus if(str_to_lower(school_type_focus) == "all") { - school_type_focus <- unique(WI_schools %>% filter(CTY_DIST %in% str_to_title(county_focus)) %>% pull(SCHOOLTYPE)) + school_type_focus <- unique(WI_schools %>% pull(SCHOOLTYPE)) } # set which school types to generate figures for district_focus <- run_parameters$district_focus if(str_to_lower(district_focus) == "all") { - district_focus <- unique(WI_schools %>% filter(CTY_DIST %in% str_to_title(county_focus), SCHOOLTYPE %in% school_type_focus, !is.na(DISTRICT_NAME)) %>% pull(DISTRICT_NAME)) + district_focus <- unique(WI_schools %>% pull(DISTRICT_NAME)) } -school_number <- length(unique(WI_schools %>% filter(CTY_DIST %in% str_to_title(county_focus), +school_number <- length(unique(WI_schools %>% filter(str_to_upper(CTY_DIST) %in% county_focus, SCHOOLTYPE %in% school_type_focus, DISTRICT_NAME %in% district_focus) %>% pull(district_school))) @@ -257,9 +257,12 @@ generate_school_maps <- function(district) { message(paste("***", district, "School District |")) options(ggmap.file_drawer = paste0("basemaps/districts/", district)) - dir.create(file_drawer(), recursive = TRUE, showWarnings = FALSE) - saveRDS(list(), file_drawer("index.rds")) - readRDS(file_drawer("index.rds")) + if(file.exists(paste0("basemaps/districts/", district, "/index.rds")) & !run_parameters$refresh_basemaps) { + readRDS(file_drawer("index.rds")) + } else { + dir.create(file_drawer(), recursive = TRUE, showWarnings = FALSE) + saveRDS(list(), file_drawer("index.rds")) + } file_drawer("index.rds") for(school in WI_schools %>% filter(DISTRICT_NAME %in% district, diff --git a/parameters/.gitignore b/parameters/.gitignore index 5e7d273..900ab3b 100644 --- a/parameters/.gitignore +++ b/parameters/.gitignore @@ -2,3 +2,6 @@ * # Except this file !.gitignore + +# Except the run_parameters template +!run_parameters_template.csv \ No newline at end of file diff --git a/parameters/run_parameters_template.csv b/parameters/run_parameters_template.csv new file mode 100644 index 0000000..2a58fcb --- /dev/null +++ b/parameters/run_parameters_template.csv @@ -0,0 +1,2 @@ +county_focus,school_type_focus,district_focus,parallel,refresh_basemaps +ALL,ALL,ALL,TRUE,TRUE