-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome3Pt.R
More file actions
122 lines (118 loc) · 3.05 KB
/
Home3Pt.R
File metadata and controls
122 lines (118 loc) · 3.05 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
data <- NBA_PBP_2018.19
sum = 0
sum2 = 0
high = 0
fourthEasyW = c(rep(0, 30))
fourthEasyL = c(rep(0, 30))
fqy = c(rep(0, 30))
fqn = c(rep(0, 30))
FTPt = c(rep(0, 120))
#secondQ = c(rep(0, 120))
#DRebPt = c(rep(0, 120))
#ATAT = c(rep(0, 120))
#secondQ = FTPT
#Home3Pt = FTPT
curAwayTeam = 0
test3Q = 0
test4Q = 0
curHomeTeam = 0
indicator = 0
t = 1
while(t<614517){
if(data$Quarter[t]==4 && data$Quarter[t-1]==3 && data$Quarter[t-2]==3){
if(data$HomeScore[t]-data$AwayScore[t]>4 && data$HomeScore[t]-data$AwayScore[t]<10){
test3Q = test3Q + 1
high = 1
indicator = 1
}
else if(data$AwayScore[t]-data$HomeScore[t]<10 && data$AwayScore[t]-data$HomeScore[t]>4){
test3Q = test3Q + 1
high = 1
indicator = 0
}
else{
high = 0
}
if(high==1){
for(team in 1:30){
if(data$HomeTeam[t]==vector[team]){
curHomeTeam = team
}
if(data$AwayTeam[t]==vector[team]){
curAwayTeam = team
}
}
}
}
else if(high==1 && indicator==1 && data$AwayPlay[t]=="End of Game"){
test4Q = test4Q + 1
if(data$HomeScore[t]>data$AwayScore[t]){
sum = sum + 1
for(team in 1:30){
if(data$HomeTeam[t]==vector[team]){
fourthEasyW[team] = fourthEasyW[team] + 1
}
}
}
else{
for(team in 1:30){
if(data$HomeTeam[t]==vector[team]){
fourthEasyL[team] = fourthEasyL[team] + 1
}
}
}
sum2 = sum2 + 1
}
else if(high==1 && indicator==0 && data$AwayPlay[t]=="End of Game"){
test4Q = test4Q + 1
if(data$HomeScore[t]<data$AwayScore[t]){
sum = sum + 1
for(team in 1:30){
if(data$AwayTeam[t]==vector[team]){
fourthEasyW[team] = fourthEasyW[team] + 1
}
}
}
else{
for(team in 1:30){
if(data$AwayTeam[t]==vector[team]){
fourthEasyL[team] = fourthEasyL[team] + 1
}
}
}
sum2 = sum2 + 1
}
else if(high==1 && indicator==1 && data$Quarter[t]==4){
if(grepl("3-pt", data$HomePlay[t], fixed=TRUE)){
if(grepl("makes", data$HomePlay[t], fixed=TRUE)){
fqy[curHomeTeam] = fqy[curHomeTeam] + 1
}
else{
fqn[curHomeTeam] = fqn[curHomeTeam] + 1
}
}
}
else if(high==1 && indicator==0 && data$Quarter[t]==4){
if(grepl("3-pt", data$AwayPlay[t], fixed=TRUE)){
if(grepl("makes", data$AwayPlay[t], fixed=TRUE)){
fqy[curAwayTeam] = fqy[curAwayTeam] + 1
}
else{
fqn[curAwayTeam] = fqn[curAwayTeam] + 1
}
}
}
t = t + 1
}
print(sum/sum2)
for(team in 1:30){
print(vector[team])
print(fourthEasyW[team]/(fourthEasyL[team]+fourthEasyW[team]))
print(fourthEasyW[team])
print(fqy[team]/(fqn[team]+fqy[team]))
PPP[team+90] = (fqy[team]/(fqn[team]+fqy[team]))
secondQ[team+90] = fourthEasyW[team]/(fourthEasyL[team]+fourthEasyW[team])
}
Home3Pt = PPP
summary(lm(secondQ ~ Home3Pt))
#summary(lm(secondQ ~ HomePt + Home2Pt + Home3Pt + Away2Pt + Away3Pt + AwayPt + ORebPt + DRebPt + AssistPt + Assist2Pt + Assist3Pt + FTPt + ATAT ))