---
title: 'EDA Project: WNBA data'
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Overview

This project will begin on Monday June 7th, and __conclude with a 10-15 minute presentation one week later on Thursday, June 17th during lab from 2:30 to 4 PM EDT__. The goal of this project is to practice understanding the structure of a dataset, and to practice generating and evaluating hypotheses using fundamental EDA and data visualization techniques.

## Deliverables

Your team is expected to produce `R Markdown` slides (an example template will be provided shortly) to accompany your 10-15 minute presentation with the following information:

* Explanation of the data structure of the dataset,
* __Three hypotheses__ you are interested in exploring,
* __Three data visualizations__ exploring the hypotheses, at least two of which must be multivariate.  __Each visualization must be in a different format__ from the other two, and you must have at least one categorical and one continuous visualization.
* __One clustering example__,
* Conclusions reached for the hypotheses based on your EDA and data visualizations,

## Timeline

There will be two submission deadlines:

**Friday, June 11th @ 4:00pm EST** - Each student will push their individual code for the project thus far to their GitHub accounts for review. We will then provide feedback on the code submitted.

**Thursday, June 17 @ 2:00pm EST** - Slides and full code must be completed and ready for presentation. Send your slides to Ron's email ([ryurko@andrew.cmu.edu](mailto:ryurko@andrew.cmu.edu)).  All code, visualizations, and presentations must be made in `R`. Take advantage of examples from lecture and the presentation template, but also feel free to explore material online that may be relevant!

## Data

Your team is assigned the [__WNBA shot data__](http://www.stat.cmu.edu/cmsac/sure/2021/materials/data/eda_projects/wnba_shots_2021.csv). This dataset contains all shot attempts in the 2021 WNBA season (through June 5th) accessed using the [`wehoop`](https://saiemgilani.github.io/wehoop/) package. The code chunk at the end shows how this dataset was constructed in `R`.

Each row of the dataset corresponds to a single shot attempt and has the following columns:

* `sequence_number`: number indicating order the shot attempt took place in the game
* `period_display_value`: Name display of period
* `period_number`: Period number
* `home_score`: Home team score following shot attempt
* `coordinate_x`: Horizontal location in feet of shot attempt where the hoop would be located at 25 feet
* `coordinate_y`: Vertical location in feet of shot attempt with respect to the target hoop (the hoop should be a little in front of 0 but ESPN's coordinate system is not exact)
* `scoring_play`: Indicator if shot was made or not
* `clock_display_value`: Time displayed on clock moment of shot
* `team_id`: Unique identifier for team the player is on
* `type_id`: Identifier for the shot type
* `type_text`: Text description of the shot type
* `away_score`: Away team score following the shot attempt
* `text`: Detailed text description of shot attempt
* `score_value`: Value of the shot attempt
* `participants_0_athlete_id`: Unique identifier for the first person listed in the `text` description of the shot attempt (typically the person attempting the shot unless it is blocked)
* `participants_1_athlete_id`: Unique identifier for the potential second person listed in the `text` description of the shot attempt (typically the person who assisted the shot attempt if `scoring_play == TRUE`)
* `game_id`: Unique identifier for a game
* `away_team_id`: Unique identifier for away team
* `away_team_name`: Away team name
* `away_team_mascot`: Away team mascot
* `away_team_abbrev`: Abbreviation for away team
* `away_team_name_alt`: Alternate name for away team
* `home_team_id`: Unique identifier for home team
* `home_team_name`: Home team name
* `home_team_mascot`: Home team mascot
* `home_team_abbrev`: Abbreviation for home team
* `home_team_name_alt`: Alternate name for home team
* `clock_minutes`: Minutes remaining in the period displayed on the clock 
* `clock_seconds`: Seconds remaining in the period displayed on the clock 
* `half`: Game half
* `lag_half`: Previous play's game half (can ignore)
* `lead_half`: Following play's game half (can ignore)
* `game_play_number`: number indicating order the shot attempt took place in the game (similar to sequence number it appears...)
 
Note that a full glossary of the features available for the WNBA shot data can be found [here](https://saiemgilani.github.io/wehoop/reference/load_wbb_pbp.html).

## Code to build dataset

```{r, eval = FALSE}
library(wehoop)
wnba_pbp_data <- load_wnba_pbp(2021)

# Get the shots and clean this data a bit:
wnba_shots_data <- wnba_pbp_data %>%
  filter(shooting_play)
# Remove unnecessary columns:
wnba_shots_data <- wnba_shots_data %>%
  dplyr::select(-shooting_play, -id, -participants_2_athlete_id,
                -type_abbreviation, -season, -season_type, 
                -home_team_spread, -game_spread, -home_favorite)
```


