                                ### Brandon Gorman | 1909188 ###
                                        ### TASK TWO  ###



#Question One

covidCHN <- read.csv("covidCHN.csv", header = TRUE)       #Insert the independent .csv file.
covidUK <- read.csv("covidUK.csv", header = TRUE)

covidData <- rbind(covidCHN, covidUK)                     #rbind the two data sheets together. 

                                                          #Although the data has be bound together, using the individual sheets will allow for eaiser data extraction.

covidData                                                 #View data set.



#Question Two

chnDataCases <- covidCHN [,c(5)]                          #Creates a separate variable for cases.
ukDataCases <- covidUK [,c(5)]
                                                     

par(mar=c(5,5,3,5))                                      #Ensures a tidy table format.
plot(as.numeric(chnDataCases, covidCHN[,6]),type = "l", xlab = "Days since pandemic", ylab = "Number of cases",
     main = "COVID-19 (SARS-CoV-2) cases and deaths China v UK", col= "green")

par(new = TRUE)                                          #Allows additional data to be added to the same table
plot(as.numeric(ukDataCases, covidUK[,6]), type = "l", yaxt="n", xaxt="n", xlab="", ylab = "", col = "blue")


par(new = TRUE)                                          #Allows additional data to be added to the same table
plot(as.numeric(covidCHN[,8], covidCHN[,9]), type = "l", yaxt="n", xaxt="n", xlab="", ylab = "", col = "darkgreen")

par(new = TRUE)                                          #Allows additional data to be added to the same table
plot(as.numeric(covidUK[,8], covidUK[,9]), type = "l", yaxt="n", xaxt="n", xlab="", ylab = "", col = "darkblue")

axis(side = 4)
mtext("Deaths", side = 4)

legend("bottomright", c("Cases: China", "Cases:UK", "Deaths: China", "Deaths:UK"), col = c("green", "blue", "darkgreen", "darkblue"), lty = c(1,2))



#Question Three

covidCHNDates <- read.csv("covidCHNDates.csv", header = TRUE)       #Insert the independent .csv file,as it contan the relevant data items. 
covidUKDates <- read.csv("covidUKDates.csv", header = TRUE)

chnCaseMax <-max(covidCHNDates[,6])
chnCaseMin <-min(covidCHNDates[,6])

ukCaseMax <-max(covidUKDates[,6])
ukCaseMin <-min(covidUKDates[,6])

chnCaseMean <- mean(covidCHNDates[,6])
ukCaseMean <- mean(covidUKDates[,6])

chnCaseMed <- median(covidCHNDates[,6])
ukCaseMed <- median(covidUKDates[,6])

chnCaseSD <- sd(covidCHNDates[,6])
ukCaseSD <- sd(covidUKDates[,6])



covidSummary <- data.frame(chnCaseMax, chnCaseMin, chnCaseMean, chnCaseMed, chnCaseSD,   #Combine the data together and convert the vectors to a data frame.
                           ukCaseMax, ukCaseMin, ukCaseMean, ukCaseMed, ukCaseSD)
names(covidSummary) <- c("Max Case: China", "Min Case: China", "Mean of Cases: China", "Median of Cases: China", "Standard Deviation: China",
                         "Max Case: UK", "Min Case: UK", "Mean of Cases: UK", "Median of Cases: UK", "Standard Deviation: UK" ) #Assign the column names to the data frame to assists in data identification.


covidSummary                                                        #View data set.



#Question Four

covidUKDates$date <- as.Date(covidUKDates$date)        #This converts the date feild into a date type. This will allow to eaiser filtering.

newUKCovidData <- covidUKDates[covidUKDates$date > "2020/10/01" & "2021/10/01",]  #Extract data via the date feild.


#HYPOTHESIS: The number of cases in real terms have increased. 

#perform a test t on the new_cases column. t.test(newUKCovidData[,6] 


#Obatin several points to genertate a bell curve
#testPlot = seq(-4.5,4.5,length=10000)

#Display the bell curve to confirm HYPOTHESIS
#plot(testPlot,(testPlot,df=18),col='darkblue',type='l')


