6.4 Mapping relative risks
We have mean and intervals how do we represent that? (labels)
- Add mean and intervals to data
$RR <- res$summary.fitted.values[, "mean"]
map$LL <- res$summary.fitted.values[, "0.025quant"]
map$UL <- res$summary.fitted.values[, "0.975quant"] map
- add it to the labels
(RR: relative risk)
<- colorNumeric(palette = "YlOrRd", domain = map$RR)
pal
<- sprintf("<strong> %s </strong> <br/>
labels Observed: %s <br/> Expected: %s <br/>
AFF: %s <br/> SIR: %s <br/> RR: %s (%s, %s)",
$county, map$Y, round(map$E, 2),
map$AFF, round(map$SIR, 2), round(map$RR, 2),
mapround(map$LL, 2), round(map$UL, 2)
%>% lapply(htmltools::HTML)
)
<- leaflet(map) %>%
lRR addTiles() %>%
addPolygons(
color = "grey", weight = 1, fillColor = ~ pal(RR),
fillOpacity = 0.5,
highlightOptions = highlightOptions(weight = 4),
label = labels,
labelOptions = labelOptions(
style =
list(
"font-weight" = "normal",
padding = "3px 8px"
),textsize = "15px", direction = "auto"
)%>%
) addLegend(
pal = pal, values = ~RR, opacity = 0.5, title = "RR",
position = "bottomright"
)
lRR