United States of they don't want no socialist healthcare system
I found life expectancy at birth data for “health regions” in Canada for 2015-2017 and in “census tracts” in the USA for 2010-2015.
Here is a map of these two countries, excluding areas with a life expectancy at birth lower than 0.
Data sources and shapefiles:
- Canada mortality.
- Canada shapefiles.
- USA mortality.
- USA shapefiles downloaded using the tigris package.
Libraries
The usual data wrangling libraries for spatial data (tidyverse, sf), mapped using mapview and leaflet.
tigrisis used to download USA census tract shapefiles for the year 2015.
I tried ggmap for static map, but for some reason my polygons were offset to the North of the tiles.
if(switch_generate_interim_data){
# https://www150.statcan.gc.ca/n1/pub/82-402-x/2018001/hrbf-flrs-eng.htm
download.file("https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2018001/data-donnees/boundary-limites/arcinfo/HR_000a18a-eng.zip?st=-yCcI4RR",
destfile = here::here("content/post/data/downloads/HR_000a18a-eng.zip")
)
utils::unzip(here::here("content/post/data/downloads/HR_000a18a-eng.zip"),
exdir = here::here("content/post/data/downloads/")
)
}
test avec mapviewOptions(platform = “mapdeck”)
Map of both countries excluding areas with life expectancy at birth below 80. Maine and Wisonsin are excluded because data is not available.
both <- list(
usa_mortality_with_boundary %>%
select(ID = tract_id ,
NAME = NAME,
e_0 = e_0
)%>%
st_transform(crs=4326)
,
canada_mortality_with_boundary %>%
select(ID = HR_UID,
NAME = geo2,
e_0 = value) %>%
st_transform(crs=4326)
)
# map both!
both_mortality_with_boundary <-sf::st_as_sf(
data.table::rbindlist(both))
#https://twitter.com/TimSalabim3/status/1206673522053066753
#mapviewOptions(platform = "leaflet")
mymapview <- both_mortality_with_boundary %>%
filter(e_0 > 80) %>%
mapview::mapview(zcol = "e_0",
layer.name = "Life expectancy at birth <br>
when above 80 <br>
Canada 2015-2017 <br>
USA 2010-2015")
mymapview@map %>%
addPolygons(data= usa_states %>% filter(STUSPS %in% c("ME","WI")),
color = "gray60", fillColor = "gray60")



































