Introduction:

Angel Reese was a highly regarded recruit coming out of high school, but her first year of college was cut short by injury. In Reese’s second year, she averaged a double-double in one of the premier conferences in the NCAA. Reese’s decided that she wanted a change of scenery for the rest of her college career, so she transferred to LSU. At LSU, had Reese matched her year-two production, she would be a lock for All-American, but in true Angel Reese style, she improved yet again. Reese has had a double-double each game this season (in points and total rebounds), which has allowed her to set an SEC record once held by WNBA great Slyvia Fowles. Reese has become a leading contender for National Player of the Year. And so, I chose to make Reese the focal subject of this extra credit assignment.

Necessary Packages

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(rvest)
library(tidyverse) 
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2
## ──
## ✔ ggplot2 3.4.0     ✔ purrr   1.0.1
## ✔ tibble  3.1.8     ✔ stringr 1.5.0
## ✔ tidyr   1.3.0     ✔ forcats 0.5.2
## ✔ readr   2.1.3     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()         masks stats::filter()
## ✖ readr::guess_encoding() masks rvest::guess_encoding()
## ✖ dplyr::lag()            masks stats::lag()

Downloading the data

angel_url <- 'https://herhoopstats.com/stats/ncaa/player/2023/natl/angel-reese-stats-11eb2f34-d79a-34a4-aa81-12df17ae4e1e/'

angel <- angel_url %>%
  read_html()  %>%
  html_nodes(xpath = '//*[@id="schedule"]/div/div/div/div[1]/div/table') %>%
  html_table(header = TRUE)

angel <- data.frame(angel)
game_id <- c(1:nrow(angel))

angel$game_id <- game_id

Filtering to Game Date, Total Rebounds

baskets_and_boards <- angel %>%
  select('game_id', 'Date','TRB', 'PTS')

Adding the game by game average for Points and Total Rebounds

baskets_and_boards <- baskets_and_boards %>%
  mutate(game_pts_avg = round(cummean(PTS),1),
         game_trb_avg = round(cummean(TRB),1))

knitr::kable(head(baskets_and_boards))
game_id Date TRB PTS game_pts_avg game_trb_avg
1 2022-11-07 13 31 31.0 13.0
2 2022-11-11 15 16 23.5 14.0
3 2022-11-13 15 17 21.3 14.3
4 2022-11-16 16 29 23.2 14.8
5 2022-11-20 19 23 23.2 15.6
6 2022-11-24 19 21 22.8 16.2

Adding the 6 Game Mean for Points and Total Rebounds

six_game_mean <- function(column) {
  if_else(baskets_and_boards$game_id %% 6 == 0,  cummean(column), NULL)
}

baskets_and_boards <- baskets_and_boards %>%
  mutate(six_game_pts_avg = round(six_game_mean(PTS),1),
         six_game_trb_avg = round(six_game_mean(TRB),1))

knitr::kable(head(baskets_and_boards))
game_id Date TRB PTS game_pts_avg game_trb_avg six_game_pts_avg six_game_trb_avg
1 2022-11-07 13 31 31.0 13.0 NA NA
2 2022-11-11 15 16 23.5 14.0 NA NA
3 2022-11-13 15 17 21.3 14.3 NA NA
4 2022-11-16 16 29 23.2 14.8 NA NA
5 2022-11-20 19 23 23.2 15.6 NA NA
6 2022-11-24 19 21 22.8 16.2 22.8 16.2

Conclusion:

As you can see, Reese’s numbers are consistently impressive, which you can see on a game-by-game basis in average and individual score form. I have also provided an average for both total rebounds and points on a six-game basis. These numbers are something to behold, which gives you all the more reason to tune in!