my_dataEPL <- read.csv("C:/Users/shame/OneDrive/Desktop/Research Paper/R studio/FullEPL.csv") View(my_dataEPL) my_dataEPL <- subset(my_dataEPL, HTR!="D") my_dataEPL <- subset(my_dataEPL, FTR!="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("HomeTeam", "AwayTeam", "HTR", "FTR")] %>% subset(FTR!= "D") %>% subset(HTR!="D") %>% subset(HTR==FTR) view(HTMomentum) #This is counting where the HTResult does not match the FTresult, I just called it an 'upset' HTUpset <- my_dataEPL[c("HomeTeam", "AwayTeam", "HTR", "FTR")] %>% subset(FTR!= "D") %>% subset(HTR!="D") %>% subset(HTR!=FTR) View (HTUpset) #This counts how often a draw at HT leads to a draw at FT HTMomentumDraws <- my_dataEPL[c("HomeTeam", "AwayTeam", "HTR", "FTR")] %>% subset(FTR=="D") %>% subset(HTR=="D") %>% subset(HTR==FTR) 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$HTR) view(HalfTimeResults_freq) #away winnings in HTR my_dataEPL2 <- subset(my_dataEPL, HTR!="H") #teams that won in the FTR where away won in the HTR FullTimeResults_freq_away <- table(my_dataEPL2$FTR) view(FullTimeResults_freq_away) #data where home won in the HTR my_dataEPL3 <- subset(my_dataEPL, HTR!="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. a <- FullTimeResults_freq_home["H"] b <- FullTimeResults_freq_home["A"] xH <- c(a,b) percentlabels_H <- round(100*xH/sum(xH), 1) HomePieLabels <- paste(percentlabels_H, "%", sep="") HomePie <- pie(xH, labels = HomePieLabels, main="Home Team Half Time Momentum", 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. c <- FullTimeResults_freq_away["A"] d <- FullTimeResults_freq_away["H"] xA <- c(c,d) percentlabels_A <- round(100*xA/sum(xA), 1) AwayPieLabels <- paste(percentlabels_A, "%", sep="") AwayPie <- pie(xA, labels=AwayPieLabels, main="Away Team Half Time Momentum", 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)))