Measles is a contagious disease caused by a virus. Measles cases were as high as several million several decades ago in the early 1980s. More recently, cases have decreased remarkably. Much of this decrease in cases happens within the first 15 years of our dataset, where the cases decrease from several millions to just under 1 million by 1993. In recent years (2007-2017), the annual number of cases has consistently been under 500,000.
#Question 1 Code
library(readr)
measles <- read_csv("measles.csv")
## Rows: 38 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (3): year, measles cases, vaccination coverage
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#View(measles)
measles <- measles[order(measles$year),]
barplot(measles$`measles cases`, measles$year, main="Number of measles cases between 1980 and 2017", xlab = "Year", ylab = "Number of Cases", col = c("red", "purple", "blue"), cex.axis = 0.5)
axis(side=1, measles$year, las=2)
text(1980:2017)
#I couldn't get the year to appear on the x-axis
Measles is a deadly disease. The prevalence of measles cases has decreased over the years. While measles cases have not decreased in a linear fashion, they have consistently low in recent years. This may be due to the increase in measles vaccination rates. However, we would need to see a plot of vaccination rates over the same number of years in order to see this trend.
Here we have plotted measles cases on a interactive graph. Each point is the number of annual measles cases. The year is plotted on the x-axis and the number of cases is plotted on the y-axis. Here, we have data between the years of 1985 and 2005. If you hover your mouse over a data point, you will see the year and number of cases come up. You can also zoom into different parts of the graph to see better.
#Question 2 Code
measles_new <- subset(measles, year <= 2005)
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
p <- plot_ly(data = measles_new, x = ~year, y = ~`measles cases`, type = 'scatter', mode = 'markers', marker = list(size = 10, opacity = 0.5, line = list(color="red", width = 2))) %>% layout(title = 'Number of Cases of Measles per Year Between 1980 and 2017')
p
The interactive graph shows the trend of measles cases from 1985 to 2005. I subset the data set to only include these 2 decades. There is a very large drop in the first decade between 1985 and 1995. Measles cases have remained low from 1995 to 2005. Right now 2004 is the year with the lowest number of measles cases, but we do see that there was a slight increase in 2005.
#Question 3 Code
par(mar=c(4,4,4,4))
measles <- measles[order(measles$year),]
barplot(measles$`measles cases`, measles$year, main="Number of measles cases between 1980 and 2017", xlab = "Year", ylab = "Number of Cases", col = c("red", "purple", "blue"), cex.axis = 0.5, lwd=2)
points(measles$year, measles$`vaccination coverage`*100000, type="l", col="green", lwd=2)
axis(4, at=seq(3000000, 6000000, 9000000), labels=seq(3000000, 6000000, 9000000), las=1, col="green", col.axis="green", cex.axis = 0.5)
mtext("Measles Vaccination Coverage", side=4, line=3, col="green")
measles$vacc_numbers <- measles$`vaccination coverage`*measles$`measles cases`
#I trouble shooted for several hours and nothing worked, so here you go. I gave up :)