Improving an existing choropleth map

I’m interested in environmental health data in Maine, so I visited the Maine Tracking Network site. The Maine Center for Disease Control and Prevention operates the Maine Tracking Network site, and the site contains data about environmental exposures and their health effects in Maine. I notice a new category titled “Cold-Related Illnesses,” and I look for downloadable data on Emergency Department (ED) visits for cold-related illnesses (e.g., hypothermia and frostbite). I choose the surveillance data for 2018 and notice that they also have a static Maine county choropleth map in addition to a table. I want to build an interactive version of this map, so I import the data and organize it to integrate with the map functionality in leaflet.

devtools::install_github("dkahle/ggmap")
library(ggplot2)
library(maps)
library(ggmap)
library(leaflet)
library(sf)
library(tidyverse)
library(readxl)
library(htmlwidgets)
library(htmltools)
library(shiny)

state_maine <- map_data(map = "state") %>% filter(region == "maine")
str(state_maine)
## 'data.frame':    399 obs. of  6 variables:
##  $ long     : num  -70.7 -70.8 -70.8 -70.8 -70.8 ...
##  $ lat      : num  43.1 43.1 43.1 43.1 43.2 ...
##  $ group    : num  18 18 18 18 18 18 18 18 18 18 ...
##  $ order    : int  4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 ...
##  $ region   : chr  "maine" "maine" "maine" "maine" ...
##  $ subregion: chr  NA NA NA NA ...
counties <- map_data("county")
maine_counties <- subset(counties, region == "maine") %>% rename(County = subregion, Long = long, Lat = lat, Group = group, Order = order, Region = region) %>% mutate(County = str_to_title(County))
maine_cold_illness <- read_excel("~/Downloads/ED_visits_cold_related_illnesses18.xlsx") %>% rename(County = Location) %>% mutate_at("Rate_per_100000", as.numeric)

maine_cold_illness %>% ggplot(aes(Rate_per_100000)) +
geom_histogram(color = "black", fill = "orange", bins = nclass.FD(maine_cold_illness$Rate_per_100000)) + theme_minimal()

Normality check

Before I map the data, I make a histogram to see how normally distributed my data is. The curve has kurtosis, and there are many observations at the mean. I know this may affect how the colors are mapped, leading the viewer to think there isn’t much difference in ED visits by county. Given the non-normal distribution of my data, I split the color gradient for my map into four parts using bins.

Choosing color and features

I decide to use the red, orange, and yellow colorbrewer palette to display the county rates because the scale is coded so that red indicates the highest rate of ED visits, and I believe people associate red with elevated rates. I add some interactivity to the map so that when the viewer mouses over a county, they will see the ED visit rate per 100,000 people and the 95% confidence interval. I included the 95% confidence interval because some intervals are quite wide (e.g., Piscataquis county), meaning the rate is less precise, and viewers should interpret with caution.

The interactive labels are a nice feature so viewers can see the exact data value without overloading the map with ink.