Question 1: Create a Graph Showing the Evolution of the number of measles cases between 1980 and 2017.

First, I imported and uploaded the data into R as csv file, then I proceded to enter the code for the graph. The graph shows the evolution of measles cases per year between the years 1980 and 2017.

dat<-read.csv("C:/Users/olmec/Desktop/191 Assigment 1/measles.csv",header = TRUE)
barplot(height=matrix(dat$measles.cases),main="Evolution of Annual Measles Cases 1980-2017",xlab="Years", ylab="Number of Measles Cases in Millions per Year",beside=TRUE,col=colors()[417],names.arg = c(1980:2017),axes = TRUE,axis.lty = 1,cex.axis = .6,cex.names = .6,las=2)
legend(x="topright",inset=.02,c("Measles Cases per Year"),box.lty = 0,fill=colors()[417],cex=.8)

Question 2: Create a scatter plot showing the relationship betweeen vaccinnation coverage and the number of measles cases for the 1985-2005 period only.

First, I modified the data in excell as to only include number of measles cases and vaccination coverage for the years 1985-2005. Second, I imported the data and uploaded to r as a csv file. I proceeded to create a scatter plot showing and x-axis displaying the years and two y-axis. The y-axis on the right displays the number of measles cases per year, while the y-axis on the left, displays the vaccination coverage per year. Notice that one could clearly observed the decline in measles cases from 1985-2005 as the percentage in vaccine coverage increases by year.

new<-read.csv("C:/Users/olmec/Desktop/191 Assigment 1/measles_2.csv",header=TRUE)

plot(new$year,new$measles.cases,xlab="",ylab="Number of Measles Cases in Millions per Year",pch=17,col="red",main="Number of Measles Cases vs. Vaccination Coverage 1985-2005")
par(new=TRUE)
plot(new$vaccination.coverage,axes=F,ylab="",xlab="Years",pch=15,col="blue")
axis(side=4)
mtext(side=4,line=-1,"Vaccination Coverage by % per Year")
legend("top",legend=c("Vaccination Coverage %","Number of Measles Cases"),pch=c(15,17),col=c("blue","red"),cex=.7,box.lty = 1,bg="gray")

Question 3: Answer Questions and Modified the Network Plot using at least 4 elements.

HOW WAS THE GRAPH BELLOW CREATED?

The graph was created by using the “sample_png” function. The funciton plots a number of vertices “n”, 20 in this case, and the probability “p”of drawing an edge between two vertices selected arbitrarely. Every time the function is run, it produces a different arrangements of the vertices and edges.

WHERE DOES THE NAME OF THE ALGORITHM COMES FROM?

The name of the algorythm “sample_png” produces random graphs by using the G(n,p) Erdos-Renyi model intruduced by mathematecians Paul Erdos and Alfred Reneyi in 1959.

WHAT IS THE MAXIMUM NUMBER OF ARGUMENTS THAT THIS “sample_gnp()” FUNCTION CAN TAKE?

The maximum number of arguments that the function can take are 5.These includes the following:

“n” the number of vertices. “p” the probability of drawing edges between two arbitrary vertices (G(n,p)graph. “directed” Logical, tells whether the grapah will be directed, this is default to FALSE. “loops” Logical, tells whether to add loop edges,this is default to FALSE. “…” Passed to “sample_add”

Plot the Grap:

I plotted the graph using the “sample_png”. First, I installed and uploaded the library for “igraph”. Second, I proceeded to modified the plot provided by Dr.Caillaud by using ten different elements (See code below).

install.packages("igraph")
## Installing package into 'C:/Users/olmec/Documents/R/win-library/3.5'
## (as 'lib' is unspecified)
## package 'igraph' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\olmec\AppData\Local\Temp\RtmpMlmIOd\downloaded_packages
library("igraph")
## Warning: package 'igraph' was built under R version 3.5.3
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
g <- sample_gnp(20, 1/10)
plot(g,main="Edgar's Crazy Network Plot",vertex.color=colors()[257],vertex.shape="sphere",vertex.size=16,edge.lty=20,vertex.label.color="yellow",edge.curved=1,vertex.frame.color="yellow",edge.width=1,edge.color="black")

Bonus Question:Crate a graph that shows the number of measles cases as a barplot and vaccination coverage as a line using type=“o”.

First, I imported and uploaded into R the unmodified csv version of my file. This would be the same version used for question 1. Second, I proceeded to reproduced the same barplot as question one showing the evolution of measles cases for the years 1980-2017. Using the function “par(new=T)” I was able to plot the data for vaccination coverage as a type “o” line. Using the funtion “axis(side=4)” I was able to plot a third axis on the graph showing vaccination coverage as a percentage (See code below). Just as in the scatter plot produced in question two for the years 1985-2005, one could observe that this graph covering the years 1980-2017 shows the same pattern. As the percentage of vaccine coverage increases by year, the number of measles cases declines.

dat<-read.csv("C:/Users/olmec/Desktop/191 Assigment 1/measles.csv",header = TRUE)

barplot(height=matrix(dat$measles.cases),main="Annual Measles Cases vs. Vaccination Coverage 1980-2017",xlab="Years", ylab="Number of Measles Cases in Millions per per Year",beside=TRUE,col=colors()[417],names.arg = c(1980:2017),axes = TRUE,axis.lty = 1,cex.axis = .6,cex.names = .6,las=2)
par(new=T)
plot(dat$vaccination.coverage,axes=F,ylab="",xlab="Years",col="red",lwd=2,type="o")
axis(side=4)
mtext(side=4,line=-1,"Vaccination Coverage by % per Year")