#Import data FullEPLFinal <- `FullEPLFinal.(1)` View(FullEPLFinal) #Isolate the columns we will be using for our dataset. my_dataEPL <- my_dataEPL[c(4, 5, 8, 11)] View(my_dataEPL) # Removing Draws from the HTResult and FTResult by subsetting. my_dataEPL <- subset(my_dataEPL, HTResult!="D") my_dataEPL <- subset(my_dataEPL, FTResult!="D") View(my_dataEPL) # Now, only count the instances where the HTResult is the same as the FTResult library(tidyverse) HTMomentum <- my_dataEPL[c("Home", "Away", "HTResult", "FTResult")] %>% subset(FTResult!= "D")%>% subset(HTResult!="D") %>% subset(HTResult==FTResult) View(HTMomentum) #Now looking at instances where the HTResult does not match the FTresult, calling it an 'upset' HTUpset <- my_dataEPL[c("Home", "Away", "HTResult", "FTResult")] %>% subset(FTResult!= "D") %>% subset(HTResult!="D") %>% subset(HTResult!=FTResult) View (HTUpset) #Counting how often a draw at HT leads to a draw at FT HTMomentumDraws <- my_dataEPL[c("Home", "Away", "HTResult", "FTResult")] %>% subset(FTResult=="D") %>% subset(HTResult=="D") %>% subset(HTResult==FTResult) View(HTMomentumDraws) #Now looking at the HT Frequencies HalfTimeResults_freq <- table(my_dataEPL$HTResult) view(HalfTimeResults_freq) #away winnings in HTR my_dataEPL2 <- subset(my_dataEPL, HTResult!="H") #teams that won in the FTR where away won in the HTR FullTimeResults_freq_away <- table(my_dataEPL2$FTResult) View (FullTimeResults_freq_away) #data where home won in the HTR my_dataEPL3 <- subset(my_dataEPL, HTResult!="A") #Team that won in the FTR where home won in the HTR FullTimeResults_freq_home <- table(my_dataEPL3$FTR) #Pie chart showing the amount of game won by the home team when they were in the lead at halftime. HomePieValues <- c(FullTimeResults_freq_home["H"], FullTimeResults_freq_home["A"]) percentlabels_H <- round(100*HomePieValues/sum(HomePieValues), 1) HomePieLabels <- paste(percentlabels_H, "%", sep="") HomePie <- pie(HomePieValues, labels = HomePieLabels, main="Percentage of Home teams that are leading at HT, \n win at FT", col=rainbow(length(HomePieValues))) Home_Legend <- legend("topright", c("Home Team wins at FT", "Home Team lose at FT"), cex=1, fill=rainbow(length(HomePieValues))) #Pie Chart showing the amount of games won by the Away Team when they were in the lead at halftime. AwayPieValues <- c(FullTimeResults_freq_away["A"], FullTimeResults_freq_away["H"]) percentlabels_A <- round(100*AwayPieValues/sum(AwayPieValues), 1) AwayPieLabels <- paste(percentlabels_A, "%", sep="") AwayPie <- pie(AwayPieValues, labels=AwayPieLabels, main="Percentage of Away Teams that are leading at HT, \n win at FT ", col=rainbow(length(AwayPieValues))) Away_Legend <- legend("topright",c("Away Team wins at FT","Away Team lose at FT"), cex=1, fill=rainbow(length(AwayPieValues))) #SUMMARY: # of winnings in HTR how many away won in HT and how many home won in HT HalfTimeResults <- table(my_dataEPL$HTResult) view(HalfTimeResults) #Away winnings in HTR AwayResultsHT<- subset(my_dataEPL, HTResult!="H") view(AwayResultsHT) #how many aways that won in the HTR also won in FTR FTRW <- table(AwayResultHT$FTResult) View(FTRW) #Table of HTR home winnings HomeResultHT <- subset(my_dataEPL, HTResult!="A") #how many home winnings continued to win in the second half FTRWhome <- table(HomeResultHT$FTResult) view(FTRWhome) view(FTRWhome) #SUMMARY: #Looking at the half time results, out of 1884 matches played (excluding the draws), 1147 games were won by the home team and 737 games were won by the away team. #HOME: Out of the 1147 home teams that won in the first half, 1086 home teams continued to win in the full time. Hence only 61 Home teams lost even after winning at half time. #AWAY: Out of the 737 away teams that won in the first half, 645 away teams continued to win in the full time, hence only 92 away teams lost even after winning at half time