-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf_EDA.Rmd
463 lines (376 loc) · 20.9 KB
/
cf_EDA.Rmd
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
---
title: "bowl_game_predictor"
author: "Tyler Iams"
date: "12/13/2018"
output: html_document
---
```{r, message=FALSE}
library(tidyverse)
```
```{r, message=FALSE, warning=FALSE}
# 2008 data
conf_dat_2008 <- read_csv("data/2008_conf.csv")
def_dat_2008 <- read_csv("data/2008_defense.csv")
off_dat_2008 <- read_csv("data/2008_offense.csv")
game_dat_2008 <- read_csv("data/2008_games.csv")
# 2009 data
conf_dat_2009 <- read_csv("data/2009_conf.csv")
def_dat_2009 <- read_csv("data/2009_defense.csv")
off_dat_2009 <- read_csv("data/2009_offense.csv")
game_dat_2009 <- read_csv("data/2009_games.csv")
# 2010 data
conf_dat_2010 <- read_csv("data/2010_conf.csv")
def_dat_2010 <- read_csv("data/2010_defense.csv")
off_dat_2010 <- read_csv("data/2010_offense.csv")
game_dat_2010 <- read_csv("data/2010_games.csv")
#2011 data
conf_dat_2011 <- read_csv("data/2011_conf.csv")
def_dat_2011 <- read_csv("data/2011_defense.csv")
off_dat_2011 <- read_csv("data/2011_offense.csv")
game_dat_2011 <- read_csv("data/2011_games.csv")
#2012 data
conf_dat_2012 <- read_csv("data/2012_conf.csv")
def_dat_2012 <- read_csv("data/2012_defense.csv")
off_dat_2012 <- read_csv("data/2012_offense.csv")
game_dat_2012 <- read_csv("data/2012_games.csv")
#2013 data
conf_dat_2013 <- read_csv("data/2013_conf.csv")
def_dat_2013 <- read_csv("data/2013_defense.csv")
off_dat_2013 <- read_csv("data/2013_offense.csv")
game_dat_2013 <- read_csv("data/2013_games.csv")
#2014 data
conf_dat_2014 <- read_csv("data/2014_conf.csv")
def_dat_2014 <- read_csv("data/2014_defense.csv")
off_dat_2014 <- read_csv("data/2014_offense.csv")
game_dat_2014 <- read_csv("data/2014_games.csv")
#2015 data
conf_dat_2015 <- read_csv("data/2015_conf.csv")
def_dat_2015 <- read_csv("data/2015_defense.csv")
off_dat_2015 <- read_csv("data/2015_offense.csv")
game_dat_2015 <- read_csv("data/2015_games.csv")
#2016 data
conf_dat_2016 <- read_csv("data/2016_conf.csv")
def_dat_2016 <- read_csv("data/2016_defense.csv")
off_dat_2016 <- read_csv("data/2016_offense.csv")
game_dat_2016 <- read_csv("data/2016_games.csv")
#2017 data
conf_dat_2017 <- read_csv("data/2017_conf.csv")
def_dat_2017 <- read_csv("data/2017_defense.csv")
off_dat_2017 <- read_csv("data/2017_offense.csv")
game_dat_2017 <- read_csv("data/2017_games.csv")
#2018 data
conf_dat_2018 <- read_csv("data/2018_conf.csv")
def_dat_2018 <- read_csv("data/2018_defense.csv")
off_dat_2018 <- read_csv("data/2018_offense.csv")
game_dat_2018 <- read_csv("data/2018_games.csv")
```
```{r}
#conf data
# This reads the conf_teams.csv file and formats the column names, and removes subconferences, ie if a team is in SEC West, they just become SEC. This is in order to create less levels when it is turned into a factor variable, and because we presume that differences between partitions of conferences will be negligible.
conference_list <- read_csv("data/conf_teams.csv")
conference_list <- conference_list %>% rename(School = X2, conf = X3)
conference_list <- conference_list %>% select(School, conf)
conference_list <- conference_list[-1,]
conference_list <- conference_list %>% mutate(conf = gsub("\\(West)", "", conference_list$conf))
conference_list <- conference_list %>% mutate(conf = gsub("\\(Atlantic)", "", conference_list$conf))
conference_list <- conference_list %>% mutate(conf = gsub("\\(North)", "", conference_list$conf))
conference_list <- conference_list %>% mutate(conf = gsub("\\(East)", "", conference_list$conf))
conference_list <- conference_list %>% mutate(conf = gsub("\\(South)", "", conference_list$conf))
conference_list <- conference_list %>% mutate(conf = gsub("\\(Mountain)", "", conference_list$conf))
conference_list <- conference_list %>% mutate(conf = gsub("\\(Coastal)", "", conference_list$conf))
conference_list <- conference_list %>% mutate(conf = trimws(conf))
conference_list <- conference_list %>% mutate(School = trimws(School))
```
**Functions**
**Offensive Function**
```{r}
# This formats the offensive data by renaming columns. Column names had occupied two rows, and this simplifies column names to only occupy one row.
formatter_off <- function(off_dat) {
off_dat <- off_dat %>% rename(off_rank = X1, Home = X2, games = X3, pts = X4, p_comp = Passing, p_att = Passing_1, comp_pct = Passing_2, p_yds = Passing_3, p_td = Passing_4, r_att = Rushing, r_yds = Rushing_1, r_avg = Rushing_2, r_td = Rushing_3, ttl_off_plays= `Total Offense`, ttl_off_yds = `Total Offense_1`, ttl_off_avg = `Total Offense_2`, pass_fd = `First Downs`, rush_fd = `First Downs_1`, pen_fd = `First Downs_2`, ttl_fd = `First Downs_3`, pen = Penalties, pen_yds = Penalties_1, fum = Turnovers, int = Turnovers_1, turnover = Turnovers_2)
off_dat <- off_dat[-1,]
}
off_dat_2008 <- formatter_off(off_dat_2008)
off_dat_2009 <- formatter_off(off_dat_2009)
off_dat_2010 <- formatter_off(off_dat_2010)
off_dat_2011 <- formatter_off(off_dat_2011)
off_dat_2012 <- formatter_off(off_dat_2012)
off_dat_2013 <- formatter_off(off_dat_2013)
off_dat_2014 <- formatter_off(off_dat_2014)
off_dat_2015 <- formatter_off(off_dat_2015)
off_dat_2016 <- formatter_off(off_dat_2016)
off_dat_2017 <- formatter_off(off_dat_2017)
off_dat_2018 <- formatter_off(off_dat_2018)
```
**Defensive Function**
```{r}
# This simplifies defensive data in the same way by taking two-row column headers and making them into single row column headers.
formatter_def <- function(def_dat) {
def_dat <- def_dat %>% rename(def_rank = X1, Home = X2, games = X3, opp_pts = X4, opp_p_comp = Passing, opp_p_att = Passing_1, opp_comp_pct = Passing_2, opp_p_yds = Passing_3, opp_p_td = Passing_4, opp_r_att = Rushing, opp_r_yds = Rushing_1, opp_r_avg = Rushing_2, opp_r_td = Rushing_3, opp_ttl_off_plays= `Total Offense`, opp_ttl_off_yds = `Total Offense_1`, opp_ttl_off_avg = `Total Offense_2`, opp_pass_fd = `First Downs`, opp_rush_fd = `First Downs_1`, opp_pen_fd = `First Downs_2`, opp_ttl_fd = `First Downs_3`, def_pen = Penalties, def_pen_yds = Penalties_1, opp_fum = Turnovers, opp_int = Turnovers_1, opp_turnover = Turnovers_2)
def_dat <- def_dat[-1,]
}
def_dat_2008 <- formatter_def(def_dat_2008)
def_dat_2009 <- formatter_def(def_dat_2009)
def_dat_2010 <- formatter_def(def_dat_2010)
def_dat_2011 <- formatter_def(def_dat_2011)
def_dat_2012 <- formatter_def(def_dat_2012)
def_dat_2013 <- formatter_def(def_dat_2013)
def_dat_2014 <- formatter_def(def_dat_2014)
def_dat_2015 <- formatter_def(def_dat_2015)
def_dat_2016 <- formatter_def(def_dat_2016)
def_dat_2017 <- formatter_def(def_dat_2017)
def_dat_2018 <- formatter_def(def_dat_2018)
```
```{r}
# These functions format the way the team names are presented in the game data file. Some team names included their weekly top 25 ranking, and this would disrupt the ability to join by team name later on, so we disposed of the rankings.
formatter_game1 <- function(game_dat, year) {
game_dat <- game_dat %>% mutate(Winner = gsub("\\(", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("1", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("2", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("3", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("4", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("5", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("6", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("7", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("8", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("9", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("0", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub(")", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Loser = gsub("\\(", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("1", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("2", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("3", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("4", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("5", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("6", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("7", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("8", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("9", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("0", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub(")", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(X7 = ifelse(is.na(X7 == TRUE), "vs", "@"))
game_dat <- game_dat %>% mutate(Home = ifelse(X7 == '@', Loser, Winner))
game_dat <- game_dat %>% mutate(Away = ifelse(Home == Winner, Loser, Winner))
game_dat <- game_dat %>% mutate(Outcome = factor(ifelse(Home == Winner, 1, 0)))
game_dat <- game_dat %>% mutate(Year = year)
game_dat <- game_dat %>% select(Wk, Year, Home, Away, Outcome)
}
formatter_game2 <- function(game_dat, year) {
game_dat <- game_dat %>% mutate(Winner = gsub("\\(", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("1", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("2", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("3", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("4", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("5", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("6", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("7", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("8", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("9", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub("0", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Winner = gsub(")", "", game_dat$Winner))
game_dat <- game_dat %>% mutate(Loser = gsub("\\(", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("1", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("2", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("3", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("4", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("5", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("6", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("7", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("8", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("9", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub("0", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(Loser = gsub(")", "", game_dat$Loser))
game_dat <- game_dat %>% mutate(X8 = ifelse(is.na(X8 == TRUE), "vs", "@"))
game_dat <- game_dat %>% mutate(Home = ifelse(X8 == '@', Loser, Winner))
game_dat <- game_dat %>% mutate(Away = ifelse(Home == Winner, Loser, Winner))
game_dat <- game_dat %>% mutate(Outcome = factor(ifelse(Home == Winner, 1, 0)))
game_dat <- game_dat %>% mutate(Year = year)
game_dat <- game_dat %>% select(Wk, Year, Home, Away, Outcome)
}
game_dat_2008 <- formatter_game1(game_dat_2008, 2008)
game_dat_2009 <- formatter_game1(game_dat_2009, 2009)
game_dat_2010 <- formatter_game1(game_dat_2010, 2010)
game_dat_2011 <- formatter_game1(game_dat_2011, 2011)
game_dat_2012 <- formatter_game1(game_dat_2012, 2012)
game_dat_2013 <- formatter_game2(game_dat_2013, 2013)
game_dat_2014 <- formatter_game2(game_dat_2014, 2014)
game_dat_2015 <- formatter_game2(game_dat_2015, 2015)
game_dat_2016 <- formatter_game2(game_dat_2016, 2016)
game_dat_2017 <- formatter_game2(game_dat_2017, 2017)
game_dat_2018 <- formatter_game2(game_dat_2018, 2018)
```
```{r}
# This chunk simply prepares team names for a join in all files by trimming white space surrounding the strings.
game_dat_2018 <- game_dat_2018 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2018 <- off_dat_2018 %>% mutate(Home = trimws(Home))
def_dat_2018 <- def_dat_2018 %>% mutate(Home = trimws(Home))
game_dat_2017 <- game_dat_2017 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2017 <- off_dat_2017 %>% mutate(Home = trimws(Home))
def_dat_2017 <- def_dat_2017 %>% mutate(Home = trimws(Home))
game_dat_2016 <- game_dat_2016 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2016 <- off_dat_2016 %>% mutate(Home = trimws(Home))
def_dat_2016 <- def_dat_2016 %>% mutate(Home = trimws(Home))
game_dat_2015 <- game_dat_2015 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2015 <- off_dat_2015 %>% mutate(Home = trimws(Home))
def_dat_2015 <- def_dat_2015 %>% mutate(Home = trimws(Home))
game_dat_2014 <- game_dat_2014 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2014 <- off_dat_2014 %>% mutate(Home = trimws(Home))
def_dat_2014 <- def_dat_2014 %>% mutate(Home = trimws(Home))
game_dat_2013 <- game_dat_2013 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2013 <- off_dat_2013 %>% mutate(Home = trimws(Home))
def_dat_2013 <- def_dat_2013 %>% mutate(Home = trimws(Home))
game_dat_2012 <- game_dat_2012 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2012 <- off_dat_2012 %>% mutate(Home = trimws(Home))
def_dat_2012 <- def_dat_2012 %>% mutate(Home = trimws(Home))
game_dat_2011 <- game_dat_2011 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2011 <- off_dat_2011 %>% mutate(Home = trimws(Home))
def_dat_2011 <- def_dat_2011 %>% mutate(Home = trimws(Home))
game_dat_2010 <- game_dat_2010 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2010 <- off_dat_2010 %>% mutate(Home = trimws(Home))
def_dat_2010 <- def_dat_2010 %>% mutate(Home = trimws(Home))
game_dat_2009 <- game_dat_2009 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2009 <- off_dat_2009 %>% mutate(Home = trimws(Home))
def_dat_2009 <- def_dat_2009 %>% mutate(Home = trimws(Home))
game_dat_2008 <- game_dat_2008 %>% mutate(Home = trimws(Home),
Away = trimws(Away))
off_dat_2008 <- off_dat_2008 %>% mutate(Home = trimws(Home))
def_dat_2008 <- def_dat_2008 %>% mutate(Home = trimws(Home))
```
```{r}
# These functions modify some team names from the game data table. In our offense and defensive tables the team names were sometimes presented with slightly different representations of the same team, and therefore we needed to reformat one in order for joins to work properly.
fix_up_home <- function(dat) {
dat <- dat %>% mutate(Home = trimws(Home),
Away = trimws(Away),
Home = ifelse(Home == "Alabama-Birmingham", "UAB",
ifelse(Home == "Miami OH", "Miami (OH)",
ifelse(Home == "Mississippi", "Ole Miss",
ifelse(Home == "Texas-El Paso", "UTEP",
ifelse(Home == "Pittsburgh", "Pitt",
ifelse(Home == "Southern California", "USC",
ifelse(Home == "Louisiana State", "LSU",
ifelse(Home == "Southern Methodist", "SMU",
ifelse(Home == "Texas-San Antonio", "UTSA",
ifelse(Home == "Central Florida", "UCF",
ifelse(Home == "Miami FL", "Miami (FL)",
ifelse(Home == "Nevada-Las Vegas", "UNLV", Home)))))))))))))
}
fix_up_away <- function(dat) {
dat <- dat %>% mutate(Home = trimws(Home),
Away = trimws(Away),
Away = ifelse(Away == "Alabama-Birmingham", "UAB",
ifelse(Away == "Miami OH", "Miami (OH)",
ifelse(Away == "Mississippi", "Ole Miss",
ifelse(Away == "Texas-El Paso", "UTEP",
ifelse(Away == "Pittsburgh", "Pitt",
ifelse(Away == "Southern California", "USC",
ifelse(Away == "Louisiana State", "LSU",
ifelse(Away == "Southern Methodist", "SMU",
ifelse(Away == "Texas-San Antonio", "UTSA",
ifelse(Away == "Central Florida", "UCF",
ifelse(Away == "Miami FL", "Miami (FL)",
ifelse(Away == "Nevada-Las Vegas", "UNLV", Away)))))))))))))
}
game_dat_2018 <- fix_up_home(game_dat_2018)
game_dat_2018 <- fix_up_away(game_dat_2018)
game_dat_2017 <- fix_up_home(game_dat_2017)
game_dat_2017 <- fix_up_away(game_dat_2017)
game_dat_2016 <- fix_up_home(game_dat_2016)
game_dat_2016 <- fix_up_away(game_dat_2016)
game_dat_2015 <- fix_up_home(game_dat_2015)
game_dat_2015 <- fix_up_away(game_dat_2015)
game_dat_2014 <- fix_up_home(game_dat_2014)
game_dat_2014 <- fix_up_away(game_dat_2014)
game_dat_2013 <- fix_up_home(game_dat_2013)
game_dat_2013 <- fix_up_away(game_dat_2013)
game_dat_2012 <- fix_up_home(game_dat_2012)
game_dat_2012 <- fix_up_away(game_dat_2012)
game_dat_2011 <- fix_up_home(game_dat_2011)
game_dat_2011 <- fix_up_away(game_dat_2011)
game_dat_2010 <- fix_up_home(game_dat_2010)
game_dat_2010 <- fix_up_away(game_dat_2010)
game_dat_2009 <- fix_up_home(game_dat_2009)
game_dat_2009 <- fix_up_away(game_dat_2009)
game_dat_2008 <- fix_up_home(game_dat_2008)
game_dat_2008 <- fix_up_away(game_dat_2008)
```
```{r}
# This chunk simply joins the offensive and defensive data for all years.
team_dat_2018 <- full_join(off_dat_2018, def_dat_2018, "Home")
team_dat_2017 <- full_join(off_dat_2017, def_dat_2017, "Home")
team_dat_2016 <- full_join(off_dat_2016, def_dat_2016, "Home")
team_dat_2015 <- full_join(off_dat_2015, def_dat_2015, "Home")
team_dat_2014 <- full_join(off_dat_2014, def_dat_2014, "Home")
team_dat_2013 <- full_join(off_dat_2013, def_dat_2013, "Home")
team_dat_2012 <- full_join(off_dat_2012, def_dat_2012, "Home")
team_dat_2011 <- full_join(off_dat_2011, def_dat_2011, "Home")
team_dat_2010 <- full_join(off_dat_2010, def_dat_2010, "Home")
team_dat_2009 <- full_join(off_dat_2009, def_dat_2009, "Home")
team_dat_2008 <- full_join(off_dat_2008, def_dat_2008, "Home")
```
```{r}
game_dat_2018 <- full_join(game_dat_2018, team_dat_2018, "Home")
game_dat_2017 <- full_join(game_dat_2017, team_dat_2017, "Home")
game_dat_2016 <- full_join(game_dat_2016, team_dat_2016, "Home")
game_dat_2015 <- full_join(game_dat_2015, team_dat_2015, "Home")
game_dat_2014 <- full_join(game_dat_2014, team_dat_2014, "Home")
game_dat_2013 <- full_join(game_dat_2013, team_dat_2013, "Home")
game_dat_2012 <- full_join(game_dat_2012, team_dat_2012, "Home")
game_dat_2011 <- full_join(game_dat_2011, team_dat_2011, "Home")
game_dat_2010 <- full_join(game_dat_2010, team_dat_2010, "Home")
game_dat_2009 <- full_join(game_dat_2009, team_dat_2009, "Home")
game_dat_2008 <- full_join(game_dat_2008, team_dat_2008, "Home")
```
```{r}
reformat <- function(dat) {
dat <- dat %>% rename(Away = Home)
}
team_dat_2018 <- reformat(team_dat_2018)
team_dat_2017 <- reformat(team_dat_2017)
team_dat_2016 <- reformat(team_dat_2016)
team_dat_2015 <- reformat(team_dat_2015)
team_dat_2014 <- reformat(team_dat_2014)
team_dat_2013 <- reformat(team_dat_2013)
team_dat_2012 <- reformat(team_dat_2012)
team_dat_2011 <- reformat(team_dat_2011)
team_dat_2010 <- reformat(team_dat_2010)
team_dat_2009 <- reformat(team_dat_2009)
team_dat_2008 <- reformat(team_dat_2008)
```
```{r}
game_dat_2018 <- full_join(game_dat_2018, team_dat_2018, "Away")
game_dat_2017 <- full_join(game_dat_2017, team_dat_2017, "Away")
game_dat_2016 <- full_join(game_dat_2016, team_dat_2016, "Away")
game_dat_2015 <- full_join(game_dat_2015, team_dat_2015, "Away")
game_dat_2014 <- full_join(game_dat_2014, team_dat_2014, "Away")
game_dat_2013 <- full_join(game_dat_2013, team_dat_2013, "Away")
game_dat_2012 <- full_join(game_dat_2012, team_dat_2012, "Away")
game_dat_2011 <- full_join(game_dat_2011, team_dat_2011, "Away")
game_dat_2010 <- full_join(game_dat_2010, team_dat_2010, "Away")
game_dat_2009 <- full_join(game_dat_2009, team_dat_2009, "Away")
game_dat_2008 <- full_join(game_dat_2008, team_dat_2008, "Away")
```
```{r}
game_dat_2018 <- game_dat_2018 %>% na.omit()
game_dat_2017 <- game_dat_2017 %>% na.omit()
game_dat_2016 <- game_dat_2016 %>% na.omit()
game_dat_2015 <- game_dat_2015 %>% na.omit()
game_dat_2014 <- game_dat_2014 %>% na.omit()
game_dat_2013 <- game_dat_2013 %>% na.omit()
game_dat_2012 <- game_dat_2012 %>% na.omit()
game_dat_2011 <- game_dat_2011 %>% na.omit()
game_dat_2010 <- game_dat_2010 %>% na.omit()
game_dat_2009 <- game_dat_2009 %>% na.omit()
game_dat_2008 <- game_dat_2008 %>% na.omit()
```
**Explore the Data**
```{r}
```