my_dataEPL <- read.csv("C:/Users/shame/OneDrive/Desktop/Research Paper/R studio/FullEPLFinal.csv") View(my_dataEPL) my_dataEPL <- subset(my_dataEPL, HTResult!="D") my_dataEPL <- subset(my_dataEPL, FTResult!="D") View(my_dataEPL) # Basically just subsetting a few times over. Removing Draws from the HTResult and FTResult, # then only counting instances where the HTResult is the same as the FTResult HTMomentum <- my_dataEPL[c("Home", "Away", "HTResult", "FTResult")] %>% subset(FTResult!= "D")%>% subset(HTResult!="D") %>% subset(HTResult==FTResult) View(HTMomentum) #This is counting where the HTResult does not match the FTresult, I just called it an 'upset' HTUpset <- my_dataEPL[c("Home", "Away", "HTResult", "FTResult")] %>% subset(FTResult!= "D") %>% subset(HTResult!="D") %>% subset(HTResult!=FTResult) View (HTUpset) #This counts 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) #Using a histogram to show that teams that win in the half time results, generally win in the full time results. 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(xH, labels = HomePieLabels, main="Percentage of Home teams that win at FT when in the lead at HT", col=rainbow(length(xH))) Home_Legend <- legend("topright", c("Home Team wins at FT", "Home Team lose at FT"), cex=1, fill=rainbow(length(xH))) #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(xA, labels=AwayPieLabels, main="Percentage of Away Teams that wins at FT when in the lead at HT", col=rainbow(length(xA))) Away_Legend <- legend("topright",c("Away Team wins at FT","Away Team lose at FT"), cex=1, fill=rainbow(length(xA)))