Introduction

The elderly are most severely affected by flu-related illnesses and are most likely to die from the flu. So for this assignment I wanted to look at the prevalence of elderly (age 65+) in each state, as well as the percent of that population that received a flu shot in the past 12 months.

Setup

Loading Libraries

First I loaded the libraries I’ll need.

library(dplyr)
library(knitr)
library(leaflet)
library(rgdal)

Importing Datasets

Next I imported my csv files and my shapefile. The two csv files are BRFSS data from the CDC and the shapefile is from the US Census Bureau.

age <- read.csv("age.csv")
immunizations <- read.csv("immunizations.csv")
states <- readOGR("./states", "states")

Setting Up the Shapefile

Next I set up my shapefile to make sure that the state borders looked ok. The file includes U.S. states and territories, so I needed to set boundaries to limit the view to exclude territories.

names(states)
## [1] "STATEFP"  "STATENS"  "AFFGEOID" "GEOID"    "STUSPS"   "NAME"    
## [7] "LSAD"     "ALAND"    "AWATER"
states <- spTransform(states, CRS("+proj=longlat +datum=WGS84"))

leaflet() %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = states, popup = ~NAME) %>% 
  fitBounds(-120, 47, -72, 29)

Elderly Population by State

10 Oldest States

Next I wanted to see which states had the highest proportion of their population aged 65 or older. To do this I cleaned up my dataframe by exluding U.S. territories and national averages. I also discared all age groups other than age 65+. Then I selected only the columns I needed; LocationDesc (state names) and Data_Value (the percent of the population in that age category). Finally, I created a table of the 10 oldest states.

age65 <- age[-c(1:12, 319:334),] %>% filter(Response== "65+ years") %>% select(LocationDesc, Data_Value)

age65_top <- age65 %>% arrange(desc(Data_Value))  %>%
  transmute(State= paste(LocationDesc), Prevalence= paste(Data_Value)) %>% top_n(10)
## Selecting by Prevalence
kable(age65_top)
State Prevalence
Florida 24.1
Maine 22.7
West Virginia 22.6
Montana 21.6
Pennsylvania 21.6
Iowa 21.1
Vermont 21
Arkansas 20.9
Delaware 20.9
Arizona 20.6
Hawaii 20.6

Map of Elderly by State

To get a better idea of which states have the most elderly, and which have the fewest, I merged my age dataframe with my shapefile and split the states into quartiles by percent of the population over 65. The darker green states have the highest percent of persons age 65 or older, while the lighter green states have the lowest percentage.

age65_states <- merge(states, age65, by.x="NAME", by.y="LocationDesc")
pal <- colorQuantile("Greens", NULL, n = 4)

popup_value <- paste("<strong>Percent 65+: </strong>", age65_states$Data_Value)

leaflet() %>% 
  addProviderTiles("Stamen.Toner") %>% 
  addPolygons(data = age65_states,
              fillColor = ~pal(Data_Value),
              color = "#BDBDC3", 
              fillOpacity = 1,
              weight = 1, 
              popup=~popup_value) %>% fitBounds(-120, 47, -72, 29)

Immunization Rate by State

10 Best States

Now that I know which states have the most elderly persons, I wanted to look at which states had the highest rates of flu immunization among elderly in the past 12 months. I had a similar approach to this as I did for the age dataset. I first cleaned the my immunization dataframe so that it contained only the information I needed, and then I created a table with the 10 states that had the highest immunization rates.

immunizations2 <- immunizations[-c(1:4, 107:124),] %>% filter(Response== "Yes")

immunizations_top <- immunizations2 %>% arrange(desc(Data_Value)) %>% 
  select(LocationDesc, Data_Value) %>% 
  transmute(State= paste(LocationDesc), Prevalence= paste(Data_Value)) %>% top_n(10)
## Selecting by Prevalence
kable(immunizations_top)
State Prevalence
South Dakota 70.7
West Virginia 69.8
Kentucky 68.9
North Carolina 68.8
Missouri 68.3
Tennessee 67.2
Colorado 67
Oklahoma 67
Iowa 66.8
Mississippi 66.7

Map of Immunizations by State

Again I wanted to have a visual on which states were better or worse in terms of immunization rates, so I merged the immunization file and the shapefile. The states were split into quartiles by immunization rate among those age 65 and older. States with the lowest rates are in white, while the states with the highest rates are in dark purple.

immunization_states <- merge(states, immunizations2, by.x="NAME", by.y="LocationDesc")
pal <- colorQuantile("Purples", NULL, n = 4)

popup_value <- paste("<strong>Percent of 65+ Immunized: </strong>", immunization_states$Data_Value)

leaflet() %>% 
  addProviderTiles("Stamen.Toner") %>% 
  addPolygons(data = immunization_states,
              fillColor = ~pal(Data_Value),
              color = "#BDBDC3", 
              fillOpacity = 1,
              weight = 1, 
              popup=~popup_value) %>% fitBounds(-120, 47, -72, 29)

Conclusions

I found it interesting that Maine was the second oldest state in the country, but did not have one of the top immunization rates. It was in the top 50% for immunization rates, but there is definitely room for improvement. Florida was the oldest state, and they were worse than Maine, in the bottom quartile for flu immunizations. Iowa and West Virginia were in both to 10 lists; the oldest 10 states, and the highest immunization rates. Both of these states have large rural areas and a few smaller cities, so Maine may be able to look to them for ways to improve our immunization rates.