diff --git a/code/map_correlation.R b/code/map_correlation.R index 106a74f..db9cf85 100644 --- a/code/map_correlation.R +++ b/code/map_correlation.R @@ -1,4 +1,5 @@ library(ggpubr) +library(htmlwidgets) # run 01_prepare-data.R first - need school_dist_shp, map_sf source("code/01_prepare-data.R") @@ -49,8 +50,9 @@ p_plot <- ggplot(school_dist_shp, data_id = school_dis)) + stat_cor(method="pearson") + geom_point_interactive(size = (school_dist_shp$total_enrollment)/10000, - aes(tooltip = paste0("School District: ", school_dis, "
", + aes(tooltip = paste0("District: ", school_dis, "
", "SBHCs: ", num_sbhcs, "
", + "Total Enrollment: ", formatC(total_enrollment, format="f", big.mark=",", digits=0), "
", "Poverty: ", round(percent_poverty*100,0), "%"))) + scale_color_distiller(direction = 1) + guides(color="none")+ @@ -74,8 +76,8 @@ map_plot <- girafe(ggobj = p_plot + p_map, width_svg = 10, height_svg = 5.5) %> #opts_hover(css = "stroke-width: 4; opacity: 1; color:orange"), opts_toolbar(pngname = "poverty_correlation") ) - -htmltools::save_html(map_plot, "visuals/poverty-correlation-map_interactive.html") +map_plot %>% + saveWidget(file = "visuals/poverty-correlation-map_interactive.html") # ---- Asthma x SBHCs ---- @@ -107,8 +109,9 @@ a_plot <- ggplot(school_dist_shp, data_id = school_dis)) + stat_cor(method="pearson") + geom_point_interactive(size = (school_dist_shp$total_enrollment)/10000, - aes(tooltip = paste0("School District: ", school_dis, "
", + aes(tooltip = paste0("District ", school_dis, "
", "SBHCs: ", num_sbhcs, "
", + "Total Enrollment: ", formatC(total_enrollment, format="f", big.mark=",", digits=0), "
", "Asthma: ", round(percent_asthma*100,0), "%"))) + scale_color_distiller(direction = 1) + guides(color="none")+ @@ -164,8 +167,9 @@ d1_plot <- ggplot(school_dist_shp, data_id = school_dis)) + stat_cor(method="pearson") + geom_point_interactive(size = (school_dist_shp$total_enrollment)/10000, - aes(tooltip = paste0("School District: ", school_dis, "
", + aes(tooltip = paste0("District ", school_dis, "
", "SBHCs: ", num_sbhcs, "
", + "Total Enrollment: ", formatC(total_enrollment, format="f", big.mark=",", digits=0), "
", "Diabetes 1: ", round(percent_diabetes1*100,2), "%"))) + scale_color_distiller(direction = 1) + guides(color="none") + @@ -216,7 +220,8 @@ d2_plot <- ggplot(school_dist_shp, data_id = school_dis)) + stat_cor(method="pearson") + geom_point_interactive(size = (school_dist_shp$total_enrollment)/10000, - aes(tooltip = paste0("School District: ", school_dis, "
", + aes(tooltip = paste0("District ", school_dis, "
", + "Total Enrollment: ", formatC(total_enrollment, format="f", big.mark=",", digits=0), "
", "SBHCs: ", num_sbhcs, "
", "Diabetes 2: ", round(percent_diabetes2*100,2), "%"))) + scale_color_distiller(direction = 1) + @@ -268,7 +273,8 @@ an_plot <- ggplot(school_dist_shp, data_id = school_dis)) + stat_cor(method="pearson") + geom_point_interactive(size = (school_dist_shp$total_enrollment)/10000, - aes(tooltip = paste0("School District: ", school_dis, "
", + aes(tooltip = paste0("District ", school_dis, "
", + "Total Enrollment: ", formatC(total_enrollment, format="f", big.mark=",", digits=0), "
", "SBHCs: ", num_sbhcs, "
", "Anaphylaxis: ", round(percent_anaphylaxis*100,0), "%"))) + scale_color_distiller(direction = 1) + diff --git a/visuals/anaphylaxis-correlation-map_interactive.html b/visuals/anaphylaxis-correlation-map_interactive.html index e696cc9..de4bdd7 100644 --- a/visuals/anaphylaxis-correlation-map_interactive.html +++ b/visuals/anaphylaxis-correlation-map_interactive.html @@ -947,9 +947,9 @@
-
+
- - + + diff --git a/visuals/asthma-correlation-map_interactive.html b/visuals/asthma-correlation-map_interactive.html index b6864c3..42642c1 100644 --- a/visuals/asthma-correlation-map_interactive.html +++ b/visuals/asthma-correlation-map_interactive.html @@ -947,9 +947,9 @@
-
+
- - + + diff --git a/visuals/diabetes1-correlation-map_interactive.html b/visuals/diabetes1-correlation-map_interactive.html index 772c1d3..7eb4acf 100644 --- a/visuals/diabetes1-correlation-map_interactive.html +++ b/visuals/diabetes1-correlation-map_interactive.html @@ -947,9 +947,9 @@
-
+
- - + + diff --git a/visuals/diabetes2-correlation-map_interactive.html b/visuals/diabetes2-correlation-map_interactive.html index 72eed28..63d5e55 100644 --- a/visuals/diabetes2-correlation-map_interactive.html +++ b/visuals/diabetes2-correlation-map_interactive.html @@ -947,9 +947,9 @@
-
+
- - + + diff --git a/visuals/poverty-correlation-map_interactive.html b/visuals/poverty-correlation-map_interactive.html index 74d926d..a87d0a3 100644 --- a/visuals/poverty-correlation-map_interactive.html +++ b/visuals/poverty-correlation-map_interactive.html @@ -947,9 +947,9 @@
-
+
- - + +