library(knitr)
opts_chunk$set( cache=FALSE,
echo=TRUE,
message=FALSE,
warning=FALSE)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(ggthemes)
library(tidyr)
For this exercise we will work with data from the World Development Indicators (WDI). Vincent Arel-Bundock provides a nice package for R that makes it easy to import the data.
Let’s get some data on measles vaccinations. SH.IMM.MEAS
seems like a good fit. But feel free to use another variable you find
interesting.
#install.packages("WDI")
library(WDI)
WDIsearch('measles')
## indicator
## [1,] "HF.IMM.MEAS"
## [2,] "HF.IMM.MEAS.Q1"
## [3,] "HF.IMM.MEAS.Q2"
## [4,] "HF.IMM.MEAS.Q3"
## [5,] "HF.IMM.MEAS.Q4"
## [6,] "HF.IMM.MEAS.Q5"
## [7,] "SH.IMM.MEA2"
## [8,] "SH.IMM.MEAS"
## [9,] "SH.IMM.MEAS.Q1.ZS"
## [10,] "SH.IMM.MEAS.Q2.ZS"
## [11,] "SH.IMM.MEAS.Q3.ZS"
## [12,] "SH.IMM.MEAS.Q4.ZS"
## [13,] "SH.IMM.MEAS.Q5.ZS"
## name
## [1,] "Immunization, measles (% of children ages 15-23 months)"
## [2,] "Immunization, measles (% of children ages 15-23 months): Q1 (lowest)"
## [3,] "Immunization, measles (% of children ages 15-23 months): Q2"
## [4,] "Immunization, measles (% of children ages 15-23 months): Q3"
## [5,] "Immunization, measles (% of children ages 15-23 months): Q4"
## [6,] "Immunization, measles (% of children ages 15-23 months): Q5 (highest)"
## [7,] "Immunization, measles second dose (% of children by the nationally recommended age)"
## [8,] "Immunization, measles (% of children ages 12-23 months)"
## [9,] "Vaccinations (Measles) (% of children ages 12-23 months): Q1 (lowest)"
## [10,] "Vaccinations (Measles) (% of children ages 12-23 months): Q2"
## [11,] "Vaccinations (Measles) (% of children ages 12-23 months): Q3"
## [12,] "Vaccinations (Measles) (% of children ages 12-23 months): Q4"
## [13,] "Vaccinations (Measles) (% of children ages 12-23 months): Q5 (highest)"
df <- WDI(indicator = "SH.IMM.MEAS", extra = TRUE)
df <- df %>%
filter(!is.na(SH.IMM.MEAS)) %>%
filter(region != "Aggregates") %>%
select(-c(capital, longitude, latitude))