Insights/Analysis:
66% of games can be predicted by shot quality difference (postive = win, negative = loss)
Nuggets had a positive shot quality difference in 63% of games.
Nuggets won 52%(14) of games they trailed in shot quality difference.
Nuggets only won 40%(8) of games they trailed in shot quality by more than 1 percentage point.
library(tidyverse)
library(jsonlite)
library(janitor)
library(dplyr)
library(nbastatR)
library(reactable)
library(reactablefmtr)
pbp_url_opp <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Regular%2BSeason&EntityId=1610612743&EntityType=Opponent"
pbp_den_23_opp <- read_json(pbp_url_opp)
den_23_opp <- pbp_den_23_opp[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names()
opp_sq <- den_23_opp %>%
select(date,
shot_quality_avg) %>%
mutate(opp_shot_quality_avg = shot_quality_avg) %>%
select(opp_shot_quality_avg)
rf_opp <- den_23_opp %>%
select(date,
at_rim_frequency) %>%
mutate(opp_at_rim_freq = at_rim_frequency) %>%
select(opp_at_rim_freq)
pbp_url <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Regular%2BSeason&EntityId=1610612743&EntityType=Team"
pbp_den_23 <- read_json(pbp_url)
den_23 <- pbp_den_23[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names()
sq <- den_23 %>%
select(date,
shot_quality_avg)
rf <- den_23 %>%
select(date,
at_rim_frequency)
sq_anal <- cbind(sq, opp_sq) %>%
mutate( shot_qual_diff = (100*shot_quality_avg - 100*opp_shot_quality_avg) ) %>%
mutate_at(vars(shot_qual_diff), funs(round(.,4)))
nug_23 <- game_logs(
seasons = 2023,
league = "NBA",
result_types = "team",
season_types = "Regular Season"
) %>%
filter(nameTeam == "Denver Nuggets")
## Acquiring NBA basic team game logs for the 2022-23 Regular Season
nugs_wl <- nug_23 %>%
select(outcomeGame,
slugOpponent)
cbind(sq_anal, nugs_wl) %>%
select(date,
shot_quality_avg,
opp_shot_quality_avg,
shot_qual_diff,
outcomeGame,
slugOpponent) %>%
mutate( 'Team SQ' = shot_quality_avg,
'Opp SQ' = opp_shot_quality_avg,
'SQ Diff' = shot_qual_diff,
Outcome = outcomeGame,
Opponent = slugOpponent) %>%
select( date,
'Team SQ',
'Opp SQ',
'SQ Diff',
Outcome,
Opponent) %>%
mutate_at(vars('Team SQ', 'Opp SQ'), funs(round(.,4))) %>%
reactable( theme = espn(),
defaultPageSize = 20,
sortable = TRUE,
filterable = TRUE,
searchable = TRUE)
Team SQ = Team Shot Quality
Opp SQ = Opponent Shot Quality
SQ Diff = Difference in Shot Quality
Table is sortable, searchable, and filterable.