Expected points was determined by multiplying a player’s season fg% for a given zone by the value of a made shot from that zone.
If a player shoots 36% from the right corner 3, than the expected point formula would be: 3 * .36
Expected Free throw points utilizes player’s career ft% instead of just this season.
library(tidyverse)
library(nbastatR)
library(plyr)
library(dplyr)
library(reactable)
library(reactablefmtr)
library(jsonlite)
library(janitor)
library(purrr)
library(rvest)
Sys.setenv("VROOM_CONNECTION_SIZE" = 131072 * 2)
pbp_url_team <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1610612756&EntityType=Team"
pbp_team <- read_json(pbp_url_team)
team_df <- pbp_team[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names()
pbp_url_opp <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1610612756&EntityType=Opponent"
pbp_opp <- read_json(pbp_url_opp)
opp_df <- pbp_opp[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names()
team_points <- team_df %>%
select(date,
ft_points,
points)
opp_points <- opp_df %>%
mutate( opp_points = points) %>%
select(date,
opp_points)
suns_results <- right_join(team_points,opp_points) %>%
mutate( result = points - opp_points) %>%
select(date,
result,
ft_points)
#Chris Paul
pbp_url_1 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=101108&EntityType=Player"
pbp_1 <- read_json(pbp_url_1)
df_1 <- pbp_1[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( expected_ft_points = fta * .87,
'Chris Paul' = expected_ft_points) %>%
select(date,
'Chris Paul') %>%
drop_na()
#Kevin Durant
pbp_url_2 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=201142&EntityType=Player"
pbp_2 <- read_json(pbp_url_2)
df_2 <- pbp_2[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Kevin Durant' = fta * .87) %>%
select(date,
'Kevin Durant') %>%
drop_na()
#Bismack Biyombo
pbp_url_5 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=202687&EntityType=Player"
pbp_5 <- read_json(pbp_url_5)
df_5 <- pbp_5[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Bismack Biyombo' = fta * .556) %>%
select(date,
'Bismack Biyombo') %>%
drop_na()
#Devin Booker
pbp_url_7 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1626164&EntityType=Player"
pbp_7 <- read_json(pbp_url_7)
df_7 <- pbp_7[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Devin Booker' = fta * .868) %>%
select(date,
'Devin Booker') %>%
drop_na()
#Damion Lee
pbp_url_8 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1627814&EntityType=Player"
pbp_8 <- read_json(pbp_url_8)
df_8 <- pbp_8[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Damion Lee' = fta * .878) %>%
select(date,
'Damion Lee') %>%
drop_na()
#Torrey Craig
pbp_url_12 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1628470&EntityType=Player"
pbp_12 <- read_json(pbp_url_12)
df_12 <- pbp_12[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Torrey Craig' = fta * .696) %>%
select(date,
'Torrey Craig') %>%
drop_na()
#Josh Okogie
pbp_url_13 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1629006&EntityType=Player"
pbp_13 <- read_json(pbp_url_13)
df_13 <- pbp_13[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Josh Okogie' = fta * .749) %>%
select(date,
'Josh Okogie') %>%
drop_na()
#Jock Landale
pbp_url_14 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1629111&EntityType=Player"
pbp_14 <- read_json(pbp_url_14)
df_14 <- pbp_14[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Jock Landale' = fta * .84) %>%
select(date,
'Jock Landale') %>%
drop_na()
#DeAndre Ayton
pbp_url_17 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1629028&EntityType=Player"
pbp_17 <- read_json(pbp_url_17)
df_17 <- pbp_17[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names() %>%
filter( team == "PHX") %>%
mutate( 'Deandre Ayton' = fta * .755) %>%
select(date,
'Deandre Ayton') %>%
drop_na()
exp_ft <- left_join(suns_results, df_1) %>%
left_join(df_2) %>%
left_join(df_5) %>%
left_join(df_7) %>%
left_join(df_8) %>%
left_join(df_12) %>%
left_join(df_13) %>%
left_join(df_17) %>%
left_join(df_14)
exp_ft[is.na(exp_ft)] <- 0
exp_ft$'Exp. Total' <- exp_ft$'Devin Booker' +
exp_ft$'Deandre Ayton' +
exp_ft$'Kevin Durant' +
exp_ft$'Torrey Craig' +
exp_ft$'Chris Paul' +
exp_ft$'Josh Okogie' +
exp_ft$'Damion Lee' +
exp_ft$`Bismack Biyombo` +
exp_ft$`Jock Landale`
exp_ft$'Free throw luck' <- exp_ft$ft_points - exp_ft$'Exp. Total'
exp_ft <- exp_ft %>%
mutate( 'win/loss' = case_when(
result > 0 ~ "Win",
result < 0 ~ "Loss",
))
exp_ft_table <- exp_ft %>%
select(
date,
'win/loss',
'Free throw luck',
ft_points,
'Exp. Total'
) %>%
mutate_at(vars(`Free throw luck`,
`Exp. Total`), funs(round(.,2)))
pbp_url_team2 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1610612756&EntityType=Team"
pbp_team2 <- read_json(pbp_url_team2)
team_df2 <- pbp_team2[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names()
pbp_url_opp2 <- "https://api.pbpstats.com/get-game-logs/nba?Season=2022-23&SeasonType=Playoffs&EntityId=1610612756&EntityType=Opponent"
pbp_opp2 <- read_json(pbp_url_opp2)
opp_df2 <- pbp_opp2[["multi_row_table_data"]] %>%
bind_rows() %>%
clean_names()
team_points2 <- team_df2 %>%
mutate( fg_points = points - ft_points) %>%
select(date,
fg_points,
points)
opp_points2 <- opp_df2 %>%
mutate( opp_fg_points = points - ft_points,
opp_points = points) %>%
select(date,
opp_fg_points,
opp_points)
suns_results2 <- right_join(team_points2,opp_points2) %>%
mutate( result = points - opp_points) %>%
select(date,
fg_points,
result)
suns_results2$date <- gsub("-", "", as.character(suns_results2$date))
suns_results2 <- suns_results2 %>%
mutate(dateGame = date)
suns_shots_23 <- teams_shots(
teams = "Phoenix Suns",
seasons = 2023,
season_types = "Playoffs",
return_message = FALSE
)
player_1 <- suns_shots_23 %>%
filter(namePlayer == "Chris Paul")
abb3_1 <- player_1 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_1 <- player_1 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_1 <- player_1 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_1 <- player_1 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_1 <- player_1 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_1 <- player_1 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_1_exp_points <- player_1 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .461,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .491,
zoneBasic == "Mid-Range" ~ 2 * .477,
zoneBasic == "Above the Break 3" ~ 3 * .375,
zoneBasic == "Right Corner 3" ~ 3 * .5,
zoneBasic == "Left Corner 3" ~ 3 * .375,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
replace(is.na(.), 0) %>%
mutate( 'Chris Paul' = expected_points) %>%
select(dateGame,
'Chris Paul') %>%
drop_na()
player_2 <- suns_shots_23 %>%
filter(namePlayer == "Kevin Durant")
abb3_2 <- player_2 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_2 <- player_2 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_2 <- player_2 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_2 <- player_2 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_2 <- player_2 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_2 <- player_2 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_2_exp_points <- player_2 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .778,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .613,
zoneBasic == "Mid-Range" ~ 2 * .571,
zoneBasic == "Above the Break 3" ~ 3 * .373,
zoneBasic == "Right Corner 3" ~ 3 * .5,
zoneBasic == "Left Corner 3" ~ 3 * .25,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
replace(is.na(.), 0) %>%
mutate( 'Kevin Durant' = expected_points) %>%
select(dateGame,
'Kevin Durant') %>%
drop_na()
player_3 <- suns_shots_23 %>%
filter(namePlayer == "Bismack Biyombo")
abb3_3 <- player_3 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_3 <- player_3 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_3 <- player_3 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_3 <- player_3 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_3 <- player_3 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_3 <- player_3 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_3_exp_points <- player_3 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .748,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .406,
zoneBasic == "Mid-Range" ~ 2 * 0,
zoneBasic == "Above the Break 3" ~ 3 * 0,
zoneBasic == "Right Corner 3" ~ 3 * 0,
zoneBasic == "Left Corner 3" ~ 3 * 0,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
replace(is.na(.), 0) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Bismack Biyombo' = expected_points) %>%
select(dateGame,
'Bismack Biyombo') %>%
drop_na()
player_5 <- suns_shots_23 %>%
filter(namePlayer == "Terrence Ross")
abb3_5 <- player_5 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_5 <- player_5 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_5 <- player_5 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_5 <- player_5 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_5 <- player_5 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_5 <- player_5 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_5_exp_points <- player_5 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .611,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .477,
zoneBasic == "Mid-Range" ~ 2 * .474,
zoneBasic == "Above the Break 3" ~ 3 * .358,
zoneBasic == "Right Corner 3" ~ 3 * .462,
zoneBasic == "Left Corner 3" ~ 3 * .44,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Terrence Ross' = expected_points) %>%
select(dateGame,
'Terrence Ross') %>%
drop_na()
player_6 <- suns_shots_23 %>%
filter(namePlayer == "T.J. Warren")
abb3_6 <- player_6 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_6 <- player_6 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_6 <- player_6 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_6 <- player_6 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_6 <- player_6 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_6 <- player_6 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_6_exp_points <- player_6 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .784,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .476,
zoneBasic == "Mid-Range" ~ 2 * .519,
zoneBasic == "Above the Break 3" ~ 3 * .387,
zoneBasic == "Right Corner 3" ~ 3 * .0,
zoneBasic == "Left Corner 3" ~ 3 * .444,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'T.J. Warren' = expected_points) %>%
select(dateGame,
'T.J. Warren') %>%
drop_na()
player_8 <- suns_shots_23 %>%
filter(namePlayer == "Devin Booker")
abb3_8 <- player_8 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_8 <- player_8 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_8 <- player_8 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_8 <- player_8 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_8 <- player_8 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_8 <- player_8 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_8_exp_points <- player_8 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .683,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .523,
zoneBasic == "Mid-Range" ~ 2 * .494,
zoneBasic == "Above the Break 3" ~ 3 * .348,
zoneBasic == "Right Corner 3" ~ 3 * .32,
zoneBasic == "Left Corner 3" ~ 3 * .417,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Devin Booker' = expected_points) %>%
select(dateGame,
'Devin Booker') %>%
drop_na()
player_7 <- suns_shots_23 %>%
filter(namePlayer == "Cameron Payne")
abb3_7 <- player_7 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_7 <- player_7 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_7 <- player_7 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_7 <- player_7 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_7 <- player_7 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_7 <- player_7 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_7_exp_points <- player_7 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .569,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .402,
zoneBasic == "Mid-Range" ~ 2 * .4,
zoneBasic == "Above the Break 3" ~ 3 * .38,
zoneBasic == "Right Corner 3" ~ 3 * .333,
zoneBasic == "Left Corner 3" ~ 3 * .333,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Cameron Payne' = expected_points) %>%
select(dateGame,
'Cameron Payne') %>%
drop_na()
player_9 <- suns_shots_23 %>%
filter(namePlayer == "Damion Lee")
abb3_9 <- player_9 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_9 <- player_9 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_9 <- player_9 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_9 <- player_9 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_9 <- player_9 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_9 <- player_9 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_9_exp_points <- player_9 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .559,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .35,
zoneBasic == "Mid-Range" ~ 2 * .421,
zoneBasic == "Above the Break 3" ~ 3 * .403,
zoneBasic == "Right Corner 3" ~ 3 * .408,
zoneBasic == "Left Corner 3" ~ 3 * .604,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Damion Lee' = expected_points) %>%
select(dateGame,
'Damion Lee') %>%
drop_na()
player_10 <- suns_shots_23 %>%
filter(namePlayer == "Torrey Craig")
abb3_10 <- player_10 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_10 <- player_10 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_10 <- player_10 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_10 <- player_10 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_10 <- player_10 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_10 <- player_10 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_10_exp_points <- player_10 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .644,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .355,
zoneBasic == "Mid-Range" ~ 2 * .28,
zoneBasic == "Above the Break 3" ~ 3 * .354,
zoneBasic == "Right Corner 3" ~ 3 * .453,
zoneBasic == "Left Corner 3" ~ 3 * .435,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
replace(is.na(.), 0) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Torrey Craig' = expected_points) %>%
select(dateGame,
'Torrey Craig') %>%
drop_na()
player_11 <- suns_shots_23 %>%
filter(namePlayer == "Josh Okogie")
abb3_11 <- player_11 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_11 <- player_11 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_11 <- player_11 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_11 <- player_11 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_11 <- player_11 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_11 <- player_11 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_11_exp_points <- player_11 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .519,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .333,
zoneBasic == "Mid-Range" ~ 2 * .321,
zoneBasic == "Above the Break 3" ~ 3 * .352,
zoneBasic == "Right Corner 3" ~ 3 * .297,
zoneBasic == "Left Corner 3" ~ 3 * .327,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Josh Okogie' = expected_points) %>%
select(dateGame,
'Josh Okogie') %>%
drop_na()
player_12 <- suns_shots_23 %>%
filter(namePlayer == "Landry Shamet")
abb3_12 <- player_12 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_12 <- player_12 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_12 <- player_12 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_12 <- player_12 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_12 <- player_12 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_12 <- player_12 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_12_exp_points <- player_12 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .48,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .35,
zoneBasic == "Mid-Range" ~ 2 * .226,
zoneBasic == "Above the Break 3" ~ 3 * .349,
zoneBasic == "Right Corner 3" ~ 3 * .55,
zoneBasic == "Left Corner 3" ~ 3 * .423,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Landry Shamet' = expected_points) %>%
select(dateGame,
'Landry Shamet') %>%
drop_na()
player_13 <- suns_shots_23 %>%
filter(namePlayer == "Deandre Ayton")
abb3_13 <- player_13 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_13 <- player_13 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_13 <- player_13 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_13 <- player_13 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_13 <- player_13 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_13 <- player_13 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_13_exp_points <- player_13 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .782,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .515,
zoneBasic == "Mid-Range" ~ 2 * .421,
zoneBasic == "Above the Break 3" ~ 3 * .292,
zoneBasic == "Right Corner 3" ~ 3 * 0,
zoneBasic == "Left Corner 3" ~ 3 * 0,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Deandre Ayton' = expected_points) %>%
select(dateGame,
'Deandre Ayton') %>%
drop_na()
player_14 <- suns_shots_23 %>%
filter(namePlayer == "Jock Landale")
abb3_14 <- player_14 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_14 <- player_14 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_14 <- player_14 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_14 <- player_14 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_14 <- player_14 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_14 <- player_14 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_14_exp_points <- player_14 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .712,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .476,
zoneBasic == "Mid-Range" ~ 2 * .462,
zoneBasic == "Above the Break 3" ~ 3 * .25,
zoneBasic == "Right Corner 3" ~ 3 * 0,
zoneBasic == "Left Corner 3" ~ 3 * .5,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
mutate( 'Jock Landale' = expected_points) %>%
select(dateGame,
'Jock Landale') %>%
drop_na()
player_15 <- suns_shots_23 %>%
filter(namePlayer == "Ish Wainright")
abb3_15 <- player_15 %>%
filter( zoneBasic == "Above the Break 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot)) %>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( abb3_pct = accuracy * 100,
zone = "Above the Break 3")
lc3_15 <- player_15 %>%
filter( zoneBasic == "Left Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( lc3_pct = accuracy * 100,
zone = "Left Corner 3")
mr_15 <- player_15 %>%
filter( zoneBasic == "Mid-Range") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( mr_pct = accuracy * 100,
zone = "Mid-Range")
rc3_15 <- player_15 %>%
filter( zoneBasic == "Right Corner 3") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( rc3_pct = accuracy * 100,
zone = "Right Corner 3")
ip_15 <- player_15 %>%
filter( zoneBasic == "In The Paint (Non-RA)") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ip_pct = accuracy * 100,
zone = "In the Paint (non RA)")
ra_15 <- player_15 %>%
filter( zoneBasic == "Restricted Area") %>%
summarise( accuracy = mean(isShotMade),
shots = sum(isShotAttempted),
makes = sum(isShotMade),
avg_distance = mean(distanceShot))%>%
mutate_at(vars(accuracy, avg_distance), funs(round(.,4))) %>%
mutate( ra_1 = accuracy * 100,
zone = "Restricted Area")
player_15_exp_points <- player_15 %>%
mutate(
expected_points = case_when(
zoneBasic == "Restricted Area" ~ 2 * .575,
zoneBasic == "In The Paint (Non-RA)" ~ 2 * .273,
zoneBasic == "Mid-Range" ~ 2 * .333,
zoneBasic == "Above the Break 3" ~ 3 * .333,
zoneBasic == "Right Corner 3" ~ 3 * .341,
zoneBasic == "Left Corner 3" ~ 3 * .326,
)
) %>%
select(namePlayer,
idGame,
dateGame,
expected_points) %>%
group_by(dateGame) %>%
summarise_at(vars(expected_points), sum) %>%
replace(is.na(.), 0) %>%
mutate( 'Ish Wainright' = expected_points) %>%
select(dateGame,
'Ish Wainright') %>%
drop_na()
exp_points <- left_join(suns_results2, player_1_exp_points) %>%
left_join(player_2_exp_points) %>%
left_join(player_3_exp_points) %>%
left_join(player_5_exp_points) %>%
left_join(player_6_exp_points) %>%
left_join(player_7_exp_points) %>%
left_join(player_8_exp_points) %>%
left_join(player_9_exp_points) %>%
left_join(player_10_exp_points) %>%
left_join(player_11_exp_points) %>%
left_join(player_12_exp_points) %>%
left_join(player_13_exp_points) %>%
left_join(player_14_exp_points) %>%
left_join(player_15_exp_points)
exp_points[is.na(exp_points)] <- 0
exp_points$'Exp. Total' <- exp_points$`Chris Paul`+
exp_points$`Kevin Durant` +
exp_points$`Bismack Biyombo` +
exp_points$`Terrence Ross` +
exp_points$`T.J. Warren` +
exp_points$`Devin Booker` +
exp_points$`Cameron Payne` +
exp_points$`Damion Lee` +
exp_points$`Torrey Craig` +
exp_points$`Josh Okogie` +
exp_points$`Landry Shamet` +
exp_points$`Deandre Ayton` +
exp_points$`Jock Landale` +
exp_points$`Ish Wainright`
exp_points$'Field Goal luck' <- exp_points$fg_points - exp_points$'Exp. Total'
exp_points <- exp_points %>%
mutate( 'win/loss' = case_when(
result > 0 ~ "Win",
result < 0 ~ "Loss",
))
exp_table <- exp_points %>%
select(date,
fg_points,
'Exp. Total',
'Field Goal luck',
'win/loss')
exp_table2 <- exp_table %>%
mutate('Exp. FG total' = `Exp. Total`,
date2 = date) %>%
select(date2,
`Exp. FG total`,
fg_points,
`Field Goal luck`,
'win/loss')
exp_ft_table2 <- exp_ft_table %>%
mutate('Exp. FT total' = `Exp. Total`) %>%
select(date,
`Exp. FT total`,
ft_points,
`Free throw luck`)
table3 <- cbind(exp_table2,exp_ft_table2)
table3$'Total points' <- table3$fg_points + table3$ft_points
table3$'Total Exp. points' <- table3$`Exp. FG total` + table3$`Exp. FT total`
table3 %>%
select(date,
`win/loss`,
`Total points`,
`Total Exp. points`,
`Field Goal luck`,
`Free throw luck`) %>%
mutate_at(vars(`Field Goal luck`), funs(round(.,2))) %>%
reactable( theme = espn())
exp_table %>%
mutate_at(vars(`Field Goal luck`,
`Exp. Total`), funs(round(.,2))) %>%
reactable(theme = espn())
exp_points %>%
select(date,
fg_points,
`Exp. Total`,
`Kevin Durant`,
`Devin Booker`,
`Chris Paul`,
`Deandre Ayton`,
`Josh Okogie`,
`Torrey Craig`,
`Damion Lee`,
`Cameron Payne`,
`Bismack Biyombo`,
`Landry Shamet`,
`Jock Landale`,
`Ish Wainright`,
`Terrence Ross`,
`T.J. Warren`) %>%
reactable(theme = espn()) %>%
add_title("Expected FG points by player")
exp_ft_table %>%
reactable(theme = espn())
exp_ft %>%
select(
date,
'win/loss',
ft_points,
'Exp. Total',
`Kevin Durant`,
`Devin Booker`,
`Chris Paul`,
`Deandre Ayton`,
`Jock Landale`
) %>%
reactable( theme = espn()) %>%
add_title("Expected FT points by player")