-
Notifications
You must be signed in to change notification settings - Fork 145
/
2020_10_06_ncaa_womens_basketball.Rmd
189 lines (155 loc) · 5.12 KB
/
2020_10_06_ncaa_womens_basketball.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
---
title: "NCAA Women's Basketball"
date: 2020-10-06
output: html_output
---
# TidyTuesday
Join the R4DS Online Learning Community in the weekly #TidyTuesday event!
Every week we post a raw dataset, a chart or article related to that dataset, and ask you to explore the data.
While the dataset will be “tamed”, it will not always be tidy! As such you might need to apply various R for Data Science techniques to wrangle the data into a true tidy format.
The goal of TidyTuesday is to apply your R skills, get feedback, explore other’s work, and connect with the greater #RStats community!
As such we encourage everyone of all skills to participate!
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(tidytuesdayR)
library(scales)
theme_set(theme_light())
```
# Load the weekly Data
Dowload the weekly data and make available in the `tt` object.
```{r Load}
tt <- tt_load("2020-10-06")
# Tournament finish - The round of the final game for each team. OR=opening-round loss (1983 only); 1st=first-round loss; 2nd=second-round loss; RSF=loss in the Sweet 16; RF=loss in the Elite Eight; NSF=loss in the national semifinals; N2nd=national runner-up; Champ=national champions
finish_levels <- c("1st", "2nd", "RSF", "RF", "NSF", "N2nd", "Champ")
tournament <- tt$tournament %>%
filter(year >= 1994) %>%
mutate(tourney_finish = fct_relevel(tourney_finish, finish_levels),
n_rounds = as.integer(tourney_finish) - 1)
```
```{r}
tournament %>%
count(year) %>%
ggplot(aes(year, n)) +
geom_col()
```
```{r}
tournament %>%
ggplot(aes(full_w, tourney_w + reg_w)) +
geom_point(alpha = .1)
tournament %>%
filter(conf_l > reg_l)
```
* Regular wins are before the tournament
* Conf wins are a subset of regular wins
* Tournament wins are in this bracket of 64
There've been 64 teams since 1994.
```{r}
by_seed <- tournament %>%
group_by(seed) %>%
summarize(n = n(),
pct_win = mean(tourney_finish == "Champ"),
pct_final_four = mean(tourney_finish %in% c("Champ", "N2nd", "NSF")),
avg_round = mean(as.integer(tourney_finish)))
by_seed %>%
ggplot(aes(seed, avg_round)) +
geom_line() +
labs(x = "Starting seed",
y = "On average, eliminated in round...")
by_seed %>%
ggplot(aes(seed, pct_final_four)) +
geom_line() +
labs(x = "Starting seed",
y = "% of times making the Final Four")
```
```{r}
tournament %>%
count(seed, tourney_finish) %>%
group_by(seed) %>%
mutate(pct = n / sum(n)) %>%
ggplot(aes(tourney_finish, seed, fill = pct)) +
geom_tile() +
geom_text(aes(label = percent(pct))) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_reverse(breaks = seq(1, 16), expand = c(0, 0)) +
scale_fill_gradient2(high = "blue", labels = percent) +
theme(panel.grid = element_blank(),
axis.ticks = element_blank()) +
labs(x = "Tournament finish (worst to best)",
y = "Starting seed",
fill = "% of seed",
title = "When a team starts in a seed, how do they end up?")
```
Has the correlation of seededness to # of rounds changed over time?
```{r}
tournament %>%
ggplot(aes(seed, n_rounds)) +
geom_point(alpha = .1)
tournament %>%
group_by(year) %>%
summarize(correlation = cor(seed, n_rounds)) %>%
ggplot(aes(year, correlation)) +
geom_line()
```
No, the predictiveness of a seed hasn't changed in 25 years
Predicting seed + outcome from regular season / conference
```{r}
tournament %>%
ggplot(aes(seed, reg_percent)) +
geom_boxplot(aes(group = seed)) +
geom_smooth(method = "loess")
tournament %>%
mutate(conference = fct_lump(conference, 8)) %>%
ggplot(aes(seed, reg_percent)) +
geom_jitter(width = .05) +
# geom_boxplot(aes(group = seed)) +
geom_smooth(method = "loess") +
facet_wrap(~ conference)
```
```{r}
tournament %>%
ggplot(aes(reg_percent, n_rounds)) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~ seed)
tournament %>%
group_by(seed) %>%
summarize(correlation = cor(reg_percent, n_rounds))
```
### Conferences
What conferences and schools dominate the NCAA championship?
```{r}
summarize_entries <- . %>%
summarize(n_entries = n(),
avg_seed = mean(seed),
pct_win = mean(tourney_finish == "Champ"),
pct_final_four = mean(tourney_finish %in% c("Champ", "N2nd", "NSF")),
avg_round = mean(n_rounds)) %>%
arrange(desc(n_entries))
by_conference <- tournament %>%
group_by(conference) %>%
summarize_entries()
by_conference %>%
filter(n_entries >= 25) %>%
ggplot(aes(n_entries, avg_round)) +
geom_point() +
geom_text(aes(label = conference), vjust = 1, hjust = 1,
check_overlap = TRUE) +
expand_limits(x = 0)
```
```{r}
library(glue)
by_school <- tournament %>%
group_by(school) %>%
summarize_entries()
by_school %>%
filter(n_entries >= 15) %>%
mutate(school = glue("{ school } ({ n_entries})"),
school = fct_reorder(school, avg_round)) %>%
ggplot(aes(avg_round, school)) +
geom_col() +
labs(title = "Of schools that frequently play, which perform best?",
subtitle = "Parentheses show the # of years out of the last 25 they played",
x = "Average # of rounds won",
y = "")
```