Untitled
1 month ago in Plain Text
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)))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74