library(ggplot2)
Assignment #1
dat \<- read.csv("C:/Users/antho/Downloads/measles.csv",
stringsAsFactors=TRUE)) head(dat) summary(dat)
Question #1
This graph shows the evolution of measles cases over the year leading up to 2017. In the 1980s in US we there was a peak of measles cases. Leading to a mandatory measles vaccination requirement in most US states. Since then measles cases have been on steady decline. Measles was declared eliminated from the United States in 2000. This was thanks to a highly effective vaccination program in the United States.
sort(dat$year, decreasing = TRUE)
###### Sort Data in decreasing order
dat1 <- measles[order(measles$year, decreasing=FALSE),]
m1 <- dat$measles.cases/100000
barplot(height = rev(m1), weidth=dat1$year, col="blue", xlab= "Year", las= 1, main= "Evolution of Measles Cases (1980-2017)", ylab = "Measles cases (per million)", names.arg = dat1$year)
This graph shows the major decline in measles cases
in the US over the previous 4 decades. Following along with the rise in
vaccination rates of children. This shows a strong negative correlation
between vaccination and measles cases.
Question #2
As you can see, as vaccination coverage increased their was a proportional decrease in measles cases. Falling from nearly 3 million cases at below 50 percent coverage, to nearly half a million at 80% coverage.
library(plotly)
mk1 <- subset(dat, year >= 1985 & year <= 2005)
plot_ly(x= ~mk1$vaccination.coverage, y= ~mk1$measles.cases, type =
'scatter', mode = 'markers', marker = list(size = 6))%>% layout(title =
"Measles Cases vs Vaccination Coverage (1985-2005)", xaxis= list(title
="Vaccination Coverage"), yaxis= list(title ="Measles Cases"))
This chart reinforces the thesis of the
original graph, showing the sharp drop in measles cases in the from the
late 80s up till 2005. This was a period of time when the government was
staunchly commuted to eradicate this diseases, as as the vaccination
rates rose, the number of infected plummeted.
Question #3
b1 <- barplot(height = rev(m1), col="blue", xlab= "Year", las= 1, main= "Evolution of Measles Cases (1980-2017)", ylab = "Measles cases (per million)", names.arg = dat1$year)
b2 <- b1[,1]
points(b2, rev(dat$vaccination.coverage)/2.5, type="o", col="red")
par(new=TRUE)
axis(side=4, at = seq(0,40,10), labels=seq(0,40,10)*2.5, las= 1)
mtext("Vaccination Coverage (%)", side=4, line = 2)