-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvolleyball-project.Rmd
283 lines (223 loc) · 9.7 KB
/
volleyball-project.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
---
title: "Duke Sports Analtyics: Volleyball Project (Fall 2021)"
description: |
Exploring Duke Women's Volleyball statistics
author: Hillary Lee, Angel Chaudhary, Aditya Sardesai, Ethan Ouellette
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE,
comment = NA, tidy = "styler",
fig.width = 8, fig.height = 5)
```
# Introduction
Volleyball is heavily underdeveloped in terms of sports-statistics, which has
prompted us to start this project that aims to develop a WAR-like metric for
volleyball based on statistics from Duke Women's Volleyball for seasons
2018~2021. It will provide a comprehensive and hollistic approach in evaluating
players' strength and performance.
This is an explanation of the data provided on the Duke website based on the
FIVB VIS (Volleyball Information System):
| ATTACK | Description |
|------------------|-----------------------------------------------------------|
| Kills or Spikes | Number of scoring attacks. |
| Errors or Faults | Number of attacking errors. The opponent scores directly. |
| Attempts | Total number of attacks. |
| Percent | Percentage of kills out of attempts. |
| Kills Per Set | Average number of scoring attacks per set. |
| SET | Description |
|----------------------|--------------------------------------------------------------|
| Assists | Number of set assists. |
| Assists Per Set | Number of set assists per set. |
| Ball Handling Errors | Number of mistakes in setting. The opponent scores directly. |
| SERVE | Description |
|--------------|--------------------------------------------------|
| Aces | Number of points directly scored by the service. |
| Errors | Number of service mistakes. |
| Aces Per Set | Average number of serve aces per set. |
| RECEPTIONS | Description |
|----------------|---------------------------------------------|
| Errors | Number of reception errors. |
| Errors Per Set | Average number of reception errors per set. |
| DEFENSE | Description |
|--------------|---------------------------------|
| Digs | Number of outstanding digs. |
| Digs Per Set | Average number of digs per set. |
# Scraping Data
```{r packages, message = FALSE}
library(tidyverse)
```
## Duke Data
The data is scraped from Duke Sport's website: https://goduke.com/sports/vb/stats/2021?path=vb.
```{r read-duke-data}
url <- "https://goduke.com/sports/vb/stats/2021?path=vb"
Team_data_2021 <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
select(-opponents_opp) %>%
rename("2021" = duke)
url <- "https://goduke.com/sports/womens-volleyball/stats/2020"
Team_data_2020 <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
select(-opponents_opp) %>%
rename("2020" = duke)
url <- "https://goduke.com/sports/womens-volleyball/stats/2019"
Team_data_2019 <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
select(-opponents_opp) %>%
rename("2019" = duke)
Team_data_compiled <- left_join(left_join(Team_data_2021, Team_data_2020), Team_data_2019)
Team_data_compiled
```
## NCAA Data
The data is scraped from the NCAA website: https://www.ncaa.com/stats/volleyball-women/d1/
```{r read-ncaa-data}
url <- "https://www.ncaa.com/stats/volleyball-women/d1/current/team/48"
NCAA_aces_per_set <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
rename("aces per set" = per_set,
"sets" = s)
url <- "https://www.ncaa.com/stats/volleyball-women/d1/current/team/49"
NCAA_blocks_per_set <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
rename("blocks per set" = per_set,
"sets" = s)
url <- "https://www.ncaa.com/stats/volleyball-women/d1/current/team/50"
NCAA_digs_per_set <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
rename("digs per set" = per_set,
"sets" = s)
url <- "https://www.ncaa.com/stats/volleyball-women/d1/current/team/47"
NCAA_assists_per_set <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
rename("assists per set" = per_set,
"sets" = s)
url <- "https://www.ncaa.com/stats/volleyball-women/d1/current/team/46"
NCAA_kills_per_set <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
rename("kills per set" = per_set,
"sets" = s)
url <- "https://www.ncaa.com/stats/volleyball-women/d1/current/team/45"
NCAA_hitting_percentage <- xml2::read_html(url) %>%
rvest::html_table(fill = T) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
rename("sets" = s)
NCAA_kills_per_set
NCAA_hitting_percentage
NCAA_aces_per_set
NCAA_blocks_per_set
NCAA_digs_per_set
NCAA_assists_per_set
```
The following is a brief explanation of how the statistics were collected by
[NCAA regulations](http://fs.ncaa.org/Docs/stats/VB_Forms/Volleyball%20Box%20Score%20Form%20Instructions.pdf).
*Offense*
* Attack
+ A kill is awarded any time an attack attempt is unreturnable by the opposition or any time the attack attempt leads directly to a blocking error by the opponent.
+ Kills per set = total kills / sets
+ Hitting percentage = (kills - errors) / Total attacks
* Service Aces
+ A service ace is a serve that directly results in a point.
+ Aces per set = total team aces / sets
*Defense*
* Blocks
+ Total team blocks are derived by adding all block solos to one half of the block assists.
+ Blocks per set = total team blocks / sets
* Digs
+ A dig is awarded when a player successfully passes a ball that has been attacked by the opposition.
+ Digs are given only when players receive an attacked ball and it is kept in play.
+ Digs per set = total team digs / sets
* Sets
+ An assist is awarded when a player passes, sets or digs a ball to a teammate who attacks the ball for a kill.
+ Assists per set = assists / sets
```{r nitty-gritty}
library(readxl)
nitty_gritties <- read_excel("data/nitty_gritties.xlsx")
nitty_gritties
nitty_gritties_full <- read_excel("data/NCAA_Statistics.xlsx")
nitty_gritties_full
```
This data shows the RPI (rating percentage index) data for the AAC conference,
where Duke currently ranks 62nd in. The RPI is a quantity used to rank sports
teams based upon a team's wins and losses and its strength of schedule.
# Data Visualization
## Offense and Defense stats
Section authored by Hillary Lee.
### Offense
Service aces, kills, and hitting percentage are offensive stats that are compiled in this data.
```{r offense}
df1 <- NCAA_kills_per_set %>% select(-c(rank, sets))
df2 <- NCAA_aces_per_set %>% select(-c(rank, sets))
df3 <- NCAA_hitting_percentage %>% select(-c(rank, kills))
compiled_offense <- df1 %>% inner_join(df2, by = "team") %>% inner_join(df3, by = "team")
col_order <- c("team", "sets", "total_attacks", "kills", "errors", "aces", "kills per set", "pct", "aces per set")
compiled_offense <- compiled_offense[, col_order]
compiled_offense
```
### Defense
Blocks, digs, and assists are defensive stats that are compiled in this data.
```{r defense}
df1 <- NCAA_blocks_per_set %>% select(-c(rank, sets))
df2 <- NCAA_digs_per_set %>% select(-c(rank, sets))
df3 <- NCAA_assists_per_set %>% select(-c(rank))
compiled_defense <- df1 %>% inner_join(df2, by = "team") %>% inner_join(df3, by = "team")
col_order <- c("team", "sets", "block_solos", "block_assists", "digs", "assists", "blocks per set", "digs per set", "assists per set")
compiled_defense <- compiled_defense[, col_order]
compiled_defense
```
## Plotting hitting % vs. win %
Section authored by Ethan Ouellette.
```{r plot-1}
lookup <- nitty_gritties_full[ ,c("Team", "Adj. RPI Value")]
hitting_pct <- NCAA_hitting_percentage[, c("team", "pct")]
hitting_pct_rpi <- merge(lookup, hitting_pct, by.x="Team", by.y="team")
names(hitting_pct_rpi)[2] <- "rpi"
hitting_pct_rpi
ggplot(data = hitting_pct_rpi, mapping = aes(x = pct, y = rpi)) +
geom_point() +
labs(title = paste("Hitting Percentage vs. Rating Percentage Index"))
```
```{r linear model}
ncaa_and_nitty <- left_join(nitty_gritties_full, NCAA_assists_per_set,
by = c("Team" = "team")) %>%
left_join(NCAA_aces_per_set, by = c("Team" = "team")) %>%
left_join(NCAA_blocks_per_set, by = c("Team" = "team")) %>%
left_join(NCAA_digs_per_set, by = c("Team" = "team")) %>%
left_join(NCAA_hitting_percentage, by = c("Team" = "team")) %>%
left_join(NCAA_kills_per_set, by = c("Team" = "team"))
ncaa_and_nitty
```
rpi_lm <- linear_reg() %>%
set_engine("lm") %>%
fit(Adj. RPI Value ~ per_set, data = ncaa_and_nitty)
## Correlation between Home/Away Games and Winning Percentage
Section authored by Aditya Sardesai.
# Analysis
This section will be an analysis.
# Summary
This section will be a summary of the report.