Question 1

Presented is a box plot illustrating the trends in measles cases from 1985 to 2005. Measles, a highly contagious viral infection, demonstrates a decline in reported cases over the study period. Annual cases of measles are depicted on the y-axis, and the corresponding year is on the x-axis. This graph helps in understanding the historical dynamics of measles transmission.

dat <- read.csv("~/Desktop/measles.csv", stringsAsFactors=TRUE)
barplot(dat$measles.cases, names.arg = dat$year, ylim = c(0, 4500000),
main = "Annual Measles Cases and Vaccination Coverage", xlab = "Year", ylab = "Number of Cases", col = "lightskyblue")

Question 2

The relationship between measles cases and vaccination coverage from 1985 to 2005 is shown through this interactive scatter plot. Measles, a contagious viral disease, is depicted on the x-axis, vaccination coverage on the y-axis, with each colored point representing a year. Measles cases demonstrate a notable decline in reported cases concurrently with rising vaccination coverage. This visualization offers a snapshot of how vaccination efforts impact measles incidence over time.

dat <- read.csv("~/Desktop/measles.csv", stringsAsFactors=TRUE)
library(plotly)

dat1 <- dat[dat$year >= 1985 & dat$year <= 2005, ]

p <- plot_ly(data = dat1, x = ~measles.cases, y = ~vaccination.coverage, type = 'scatter', mode = 'markers', color = ~year, colors = c("red", "blue", "green")) %>%
  layout(title = 'Relationship Between Vaccination Coverage and Measles Cases',
plot_bgcolor = "#e5ecf6",
xaxis = list(title = 'Cases of Measles', range = c(300000, 3000000)), 
yaxis = list(title = 'Vaccination Coverage (%)', range = c(45, 80))) 
p

Question 3

dat <- read.csv("~/Desktop/measles.csv", stringsAsFactors=TRUE)
par(mar=c(4,4,4,4) + 0.1)

barplot(dat$measles.cases, names.arg = dat$year, ylim = c(0, 4500000),
main = "Annual Measles Cases and Vaccination Coverage", xlab = "Year", ylab = "Number of Cases", col = "lightskyblue")

par(new=TRUE)
plot(dat$vaccination.coverage,xlim=c(0,38),type="l",col = "red",axes=FALSE,ylim=c(0,100),ann=FALSE)
axis(4,at=seq(0,100,10), col = "red")
box ()
mtext("Vaccination Coverage (%)", side=4, line=3, col = "red")

To aid in creating this graph, I used a forum on Stackoverflow titled: “Adding lines to barplot in a different Y-axis in R”. I had a lot of trouble adjusting the scale right y-axis, and my linegraph was not visible. This forum helped me us the par function to overlay a second graph on top of my boxplot, thus solving this issue. Here is the link to the forum: https://stackoverflow.com/questions/15277712/adding-lines-to-barplot-in-a-different-y-axis-in-r