sac_gsw<- fread("/Users/claire/Documents/Script//NBA Stats 202223 All Stats NBA Player Props Tool.csv", header=T, data.table=F)
head(sac_gsw)
## RANK NAME TEAM POS AGE GP MPG USG% TO% FTA FT% 2PA 2P% 3PA
## 1 1 Stephen Curry Gol G 35.1 56 34.7 31.0 13.6 281 0.915 494 0.579 639
## 2 2 De'Aaron Fox Sac G 25.3 73 33.4 30.0 12.0 440 0.780 965 0.583 366
## 3 3 Klay Thompson Gol G 33.2 69 33.0 26.4 8.9 132 0.879 521 0.470 731
## 4 4 Jordan Poole Gol G 23.8 82 30.0 29.2 16.5 415 0.870 641 0.524 637
## 5 5 Domantas Sabonis Sac F-C 26.9 79 34.6 21.3 19.7 438 0.742 855 0.639 83
## 6 6 Andrew Wiggins Gol F 28.1 37 32.2 21.4 8.3 72 0.611 304 0.530 225
## 3P% eFG% TS% PPG RPG APG SPG BPG TPG P+R P+A P+R+A VI ORtg DRtg
## 1 0.427 0.614 0.656 29.4 6.1 6.3 0.9 0.4 3.2 35.5 35.7 41.8 12.0 123.4 112.1
## 2 0.325 0.557 0.599 25.0 4.2 6.1 1.1 0.3 2.5 29.2 31.1 35.3 10.3 119.2 112.2
## 3 0.412 0.556 0.576 21.9 4.1 2.4 0.7 0.4 1.8 26.0 24.2 28.4 7.3 109.6 114.2
## 4 0.336 0.514 0.573 20.4 2.7 4.5 0.8 0.3 3.1 23.2 24.9 27.7 8.4 109.1 111.5
## 5 0.373 0.632 0.668 19.1 12.3 7.3 0.8 0.5 2.9 31.4 26.4 38.7 13.8 132.5 105.7
## 6 0.396 0.557 0.564 17.1 5.0 2.3 1.2 0.8 1.3 22.1 19.4 24.4 7.2 112.9 109.6
colnames(sac_gsw)
## [1] "RANK" "NAME" "TEAM" "POS" "AGE" "GP" "MPG" "USG%" "TO%"
## [10] "FTA" "FT%" "2PA" "2P%" "3PA" "3P%" "eFG%" "TS%" "PPG"
## [19] "RPG" "APG" "SPG" "BPG" "TPG" "P+R" "P+A" "P+R+A" "VI"
## [28] "ORtg" "DRtg"
variables are:
MPG: minutes per game
USG%: Usage rate, a.k.a., usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor
TO%: A metric that estimates the number of turnovers a player commits per 100 possessions
eFG%: With eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA
TS%: True shooting percentage is a measure of shooting efficiency that takes into account field goals, 3-point field goals, and free throws
PPG: Points per game
RPG: Rebounds per game
APG: Assists per game
SPG: Steals per game
BPG: Blocks per game
TPG: Turnovers per game
VI: The versatility index is a metric that measures a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10
ORTG: Individual offensive rating is the number of points produced by a player per 100 total individual possessions
DRTG: Individual defensive rating estimates how many points the player allowed per 100 possessions he individually faced while staying on the court.
sac_gsw$TEAM[sac_gsw$TEAM=="Gol"]<- "Warriors"
sac_gsw$TEAM[sac_gsw$TEAM=="Sac"]<- "Kings"
colors<- c("Kings"="purple3", "Warriors"="goldenrod1")
the average age of the warriors is only 2 years older than the kings
tapply(sac_gsw$AGE, sac_gsw$TEAM, mean)
## Kings Warriors
## 26.40500 26.92778
ggplot(sac_gsw, aes(x = reorder(NAME, -PPG), y=PPG, fill = TEAM))+
geom_bar(stat="identity")+
labs(title="Average points per game")+
xlab("Player")+
theme_minimal()+
theme(legend.position = "bottom", axis.text.x = element_text(angle=60, size=7, hjust = 1))+
scale_fill_manual(values = colors)
not surprisingly steph has the highest PPG, followed by fox, klay and poole.
ppg<- lm(PPG~TEAM, data=sac_gsw)
tab_model(ppg)
| PPG | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 7.14 | 3.79 – 10.48 | <0.001 |
| TEAM [Warriors] | 2.39 | -2.47 – 7.24 | 0.325 |
| Observations | 38 | ||
| R2 / R2 adjusted | 0.027 / -0.000 | ||
ggplot(sac_gsw, aes(x = reorder(NAME, -TPG), y=TPG, fill = TEAM))+
geom_bar(stat="identity")+
labs(title="Average turnovers per game")+
xlab("Player")+
theme_minimal()+
theme(legend.position = "bottom", axis.text.x = element_text(angle=60, size=7, hjust = 1))+
scale_fill_manual(values = colors)
tpg<- lm(TPG~TEAM, data=sac_gsw)
tab_model(tpg)
| TPG | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 0.84 | 0.46 – 1.22 | <0.001 |
| TEAM [Warriors] | 0.50 | -0.05 – 1.05 | 0.072 |
| Observations | 38 | ||
| R2 / R2 adjusted | 0.087 / 0.061 | ||
steph and poole also have a lot of turnovers per game, but they are handling the ball a lot. there is no significant difference in turnovers per game between kings and warriors players.
ggplot(sac_gsw, aes(x = reorder(NAME, DRtg), y=DRtg, fill = TEAM))+
geom_bar(stat="identity")+
labs(title="Average defensive rating per game")+
xlab("Player")+
theme_minimal()+
theme(legend.position = "bottom", axis.text.x = element_text(angle=60, size=7, hjust = 1))+
scale_fill_manual(values = colors)
## Warning: Removed 1 rows containing missing values (`position_stack()`).
drg<- lm(DRtg~TEAM, data=sac_gsw)
tab_model(drg)
| D Rtg | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 106.84 | 104.32 – 109.36 | <0.001 |
| TEAM [Warriors] | 1.84 | -1.77 – 5.46 | 0.308 |
| Observations | 37 | ||
| R2 / R2 adjusted | 0.030 / 0.002 | ||
interestingly, defensive rating is pretty similar for almost everyone. a higher defense rating means that player is allowing more points per position. the players who then have the best are probably just playing fewer minutes by looking at this. there is no significant difference in defensive rating between the kings and warriors.
ggplot(sac_gsw, aes(x = reorder(NAME, -ORtg), y=ORtg, fill = TEAM))+
geom_bar(stat="identity")+
labs(title="Average offensive rating per game")+
xlab("Player")+
theme_minimal()+
theme(legend.position = "bottom", axis.text.x = element_text(angle=60, size=7, hjust = 1))+
scale_fill_manual(values = colors)
## Warning: Removed 1 rows containing missing values (`position_stack()`).
org<- lm(ORtg~TEAM, data=sac_gsw)
tab_model(org)
| O Rtg | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 115.03 | 107.00 – 123.05 | <0.001 |
| TEAM [Warriors] | -0.97 | -12.47 – 10.53 | 0.865 |
| Observations | 37 | ||
| R2 / R2 adjusted | 0.001 / -0.028 | ||
offensive rating is higher by bench players as well – probably due to number of minutes? not sure if it is conditioned on minutes. there is no significant difference in offensive rating between the kings and warriors either.
ggplot(sac_gsw, aes(x = reorder(NAME, -VI), y=VI, fill = TEAM))+
geom_bar(stat="identity")+
labs(title="Average versatility index per game")+
xlab("Player")+
theme_minimal()+
geom_hline(yintercept = 10, color="red", linetype="dashed", size=1)+
geom_hline(yintercept = 5, color="black", linetype="dashed", size=1)+
theme(legend.position = "bottom", axis.text.x = element_text(angle=60, size=7, hjust = 1))+
scale_fill_manual(values = colors)
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
versatility index is a measure of a player’s ability to produce in points, assists, and rebounds. The average player will score around a five on the index, while top players score above 10. the plot shows these two teams have 3 “top” players – Sabonis, Steph and Fox. Could the Kings having 2 top players be the difference maker? Almost all have an above average VI, so not sure how reliable this is, or if it needs to be conditioned on something else.
either way, Sabonis has the highest VI, which make make sense given the range of positions he plays and things he’s being asked to do.
this plot shows minutes per game (MPG) on the x axis and usage per game (USG%) on the y axis. it is indended to show players who might play a lot, but aren’t really used. I highlighed some who play more than 20 minutes per game but their usage percentage is less than 20%.
those players might be considered inefficient, but I’m not totally sure if it factors in defense, or is just based on offenseive rating.
some notables are keegan, draymond, barnes and heurter. the average usage percentage per game for the Kings = 17.6% and for the Warriors = 19.3%, so all those highlighted players are still just slightly below their team averages. however, the warriors seem to be slightly better at “using” their players
tapply(sac_gsw$`USG%`, sac_gsw$TEAM, mean)
## Kings Warriors
## 17.57500 19.28889
sac_gsw$labs<- ifelse(sac_gsw$MPG>20 & sac_gsw$`USG%`<20, sac_gsw$NAME, NA)
ggplot(sac_gsw, aes(x=MPG, y=`USG%`, color=TEAM)) +
geom_point(size=3)+
scale_color_manual(values = colors)+
geom_label_repel(aes(label = sac_gsw$labs))
## Warning: Use of `sac_gsw$labs` is discouraged.
## ℹ Use `labs` instead.
## Warning: Removed 31 rows containing missing values (`geom_label_repel()`).
this plot shows average defensive rating (DRtg) on the x axis and average offensive rating (ORrtg) on the y axis, and highlights anyone who is above 130 on ORrtg or above 115 on DRtg.
Harrison Barnes seems to be the best at both offense and defense!
sac_gsw$labs<- ifelse(sac_gsw$ORtg>130 | sac_gsw$DRtg>115, sac_gsw$NAME, NA)
ggplot(sac_gsw, aes(x=DRtg, y=ORtg, color=TEAM)) +
geom_point(size=3)+
scale_color_manual(values = colors)+
geom_label_repel(aes(label = sac_gsw$labs))
## Warning: Use of `sac_gsw$labs` is discouraged.
## ℹ Use `labs` instead.
## Warning: Removed 1 rows containing missing values (`geom_point()`).
## Warning: Removed 32 rows containing missing values (`geom_label_repel()`).
this graph shows points per game by position. guards are scoring the most points, not surprisingly. here we can see perhaps both teams tend to lack good offense out of the center.
ggplot(sac_gsw, aes(x=PPG, y=POS, color=TEAM)) +
geom_point(size=3)+
scale_color_manual(values = colors)+
geom_label_repel(aes(label = NAME))
## Warning: ggrepel: 18 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
the following analysis uses a machine learning algorithm to create profiles based on each player for the kings and warriors separately.
the analysis for the Kings shows two profiles (1 and 5) that include players who tend to get a lot of minutes per game. in cluster 1, those players get a lot of minutes (above average) and also have above average points per game, steals per game, assists per game and overall better offensive and defensive ratings. cluster 5, on the other hand, has players with above average minutes per game, higher points, steals, assists and rebounds per game, but also lower defensive ratings per game.
there is also a cluster (2) of players who do not get many minutes per game but have a lot of turnovers. cluster 6 shows players who seem to come off the bench and only shoot three pointers. cluster 4 appears to be just overall solidly average players in almost every area – not hurting the team too much.
if we look at the chart that plots defensive rating by offensive rating per game, with size indicating minutes per game and color indicating cluster, we see the starters are almost all in cluster 1! Sabonis is in cluster 5, indicating he plays a bit worse of defense than the other starters. Alex Len is in cluster 2 (lots of TOs) and Dellavedova is our shooter off the bench. Interestingly, almost all the mid-level bench players are in cluster 4, meaning our bench doesn’t seem to hurt us too much, but aren’t necessarily playing above average offense. this is really well evidenced by seeing how our starters are mostly in the first quadrant (positive-positive), and the mid-level bench guys in cluster 4 mostly cluster around the origin.
set.seed(2023)
kings<- sac_gsw %>% filter(TEAM=="Kings") %>%
select(`TO%`, `2P%`, `3P%`, RPG, APG, SPG, PPG, DRtg, ORtg, MPG) %>%
rename(TO=`TO%`,
PT2=`2P%`,
PT3=`3P%`,
Def=DRtg,
Off= ORtg)
clusITEMS<- na.omit(kings)
kclu1<-kclustering(clusITEMS)
plot(kclu1)
clu_dat<- sac_gsw %>% filter(TEAM=="Kings") %>%
select(NAME, `TO%`, `2P%`, `3P%`, RPG, APG, SPG, PPG, DRtg, ORtg, MPG) %>%
rename(TO=`TO%`,
PT2=`2P%`,
PT3=`3P%`,
Def=DRtg,
Off=ORtg)
clu_dat<- na.omit(clu_dat)
kclu2<-kclustering(clusITEMS, labels = clu_dat$NAME, k=6)
plot(kclu2)
cluster <- data.frame(kclu2$Subjects)
clu_dat<- merge(clu_dat, cluster, by.x="NAME", by.y="Label")
Xbubble_kings <- data.frame(Player=clu_dat$NAME, Off=clu_dat$Off,
Def=clu_dat$Def, cluster=as.factor(clu_dat$Cluster),
MINs=clu_dat$MPG)
labs <- c("Offensive rating", "Defensive rating", "Cluster", "Minutes per game")
bubbleplot(Xbubble_kings, id="Player", x="Off", y="Def", col="cluster", size="MINs", labels=labs)
the warriors clusters with higher minutes per game are 1 and 4. cluster 1 is players with above average minutes who tend to have decent defense, higher points per game, steals per game, assists per game and rebounds. whereas cluster 4 seems like people who are better rebounders and despite not scoring a ton (less than average points per game) they have a high offensive rating? they seem to never shoot threes, relative to the other warriors players.
the warriors also have a cluster with people who play few minutes but have a lot of turnovers. cluster 4 looks funny too– great defense, but lots of turnovers, and can only shoot 3s.
the starters all seem to be in cluster 1, and kevon looney is in cluster 4 (rebounder with high offensive rating). however, he’s the only person in cluster 4, just as Iguodala is the only person in cluster 2 (high turnover average but decent 2 point average), so this is a good lesson in probably too little data. the bubble plot with offensive and defensive rating is interesting in comparison to the plot for the kings. we know the warriors are a good team – but they don’t really seem to have players that are “standing out” above average in the first quadrant, as the kings do. instead, they have a lot of guys who cluster around the origin, which could be great for the longevity of the team and a playoff run, but might also get them into trouble.
set.seed(2023)
warriors<- sac_gsw %>% filter(TEAM=="Warriors") %>%
select(`TO%`, `2P%`, `3P%`, RPG, APG, SPG, PPG, DRtg, ORtg, MPG)%>%
rename(TO=`TO%`,
PT2=`2P%`,
PT3=`3P%`,
Def=DRtg,
Off= ORtg)
clusITEMS<- na.omit(warriors)
kclu1<-kclustering(clusITEMS)
plot(kclu1)
clu_dat<- sac_gsw %>% filter(TEAM=="Warriors") %>%
select(NAME, `TO%`, `2P%`, `3P%`, RPG, APG, SPG, PPG, DRtg, ORtg, MPG)%>%
rename(TO=`TO%`,
PT2=`2P%`,
PT3=`3P%`,
Def=DRtg,
Off= ORtg)
clu_dat<- na.omit(clu_dat)
kclu2<-kclustering(clusITEMS, labels = clu_dat$NAME, k=6)
plot(kclu2)
cluster <- data.frame(kclu2$Subjects)
clu_dat<- merge(clu_dat, cluster, by.x="NAME", by.y="Label")
Xbubble_dubs <- data.frame(Player=clu_dat$NAME, Off=clu_dat$Off,
Def=clu_dat$Def, cluster=as.factor(clu_dat$Cluster),
MINs=clu_dat$MPG)
labs <- c("Offensive rating", "Defensive rating", "Cluster", "Minutes per game")
bubbleplot(Xbubble_dubs, id="Player", x="Off", y="Def", col="cluster", size="MINs", labels=labs)
### mid series update
two games in, here is the advanced sports data:
kings<- fread("/Users/claire/Documents/Script//kings_2games.csv", header=T, data.table=F)
warriors<- fread("/Users/claire/Documents/Script//warriors_2games.csv", header=T, data.table=F)
kings$TEAM<- "Kings"
warriors$TEAM<- "Warriors"
sac_gsw2<- rbind(kings, warriors)
average efficiency field goal % through the first two games
For eFG%, three-point shots made are worth 50% more than two-point shots made. eFG% Formula=(FGM+ (0.5 x 3PM))/FGA. At least for the Kings the efficiency % isn’t too surprising to me, given our starters hadn’t been shooting great from 3. Steph and Klay have been still shooting at a pretty high clip, not so surprising either.
ggplot(sac_gsw2, aes(x = reorder(Player, -`eFG%`), y=`eFG%`, fill = TEAM))+
geom_bar(stat="identity")+
labs(title="Efficiency field goal percentage per game, through 2 playoff games")+
xlab("Player")+
theme_minimal()+
theme(legend.position = "bottom", axis.text.x = element_text(angle=60, size=7, hjust = 1))+
scale_fill_manual(values = colors)
## Warning: Removed 7 rows containing missing values (`position_stack()`).
I was curious to see who was being used most or least throughout 2 games. The most interesting is perhaps Keegan, as we’ve noticed his minutes fall. Throughout the season his usage % was around 16%, and has fallen below 10 through two games. That’s not to say he can’t still make an impact– but perhaps isn’t as ready for the playoffs.
ggplot(sac_gsw2, aes(x = reorder(Player, -`USG%`), y=`USG%`, fill = TEAM))+
geom_bar(stat="identity")+
labs(title="Usage rate per game, through 2 playoff games")+
xlab("Player")+
theme_minimal()+
theme(legend.position = "bottom", axis.text.x = element_text(angle=60, size=7, hjust = 1))+
scale_fill_manual(values = colors)
## Warning: Removed 4 rows containing missing values (`position_stack()`).
plotting offensive and defensive rating for just the first two games of the playoffs:
The Kings don’t have as a high of a defensive rating average as I might have expected given how many points they had off steals. The average defensive rating for the Warriors was 116.8 through 2 games, and only 113.2 for the Kings. Similarly, the Warriors have had a higher offensive rating per game (116.8 vs 101.7). Compared to the bubble plot from the full season, the Kings don’t have any starters in the first quadrant (above average defense and offense). Our starters are mostly all in the 4th quadrant (4th quarter fox lol) meaning they have above average offense but lower than average defense.
tapply(sac_gsw2$ORtg, sac_gsw2$TEAM, mean, na.rm=T)
## Kings Warriors
## 101.7 116.8
tapply(sac_gsw2$DRtg, sac_gsw2$TEAM, mean, na.rm=T)
## Kings Warriors
## 113.1818 116.8182
kings<- sac_gsw2 %>% filter(TEAM=="Kings")
ggplot(kings, aes(x=ORtg, y=DRtg, color=TEAM, size=MP)) +
geom_point(size=3)+
scale_color_manual(values = colors)+
geom_label_repel(aes(label = Player))+
geom_hline(yintercept = mean(kings$DRtg, na.rm=T), color="black", linetype="dotdash", size=1)+
geom_vline(xintercept = mean(kings$ORtg, na.rm=T), color="black", linetype="dotdash", size=1)
## Warning: Removed 3 rows containing missing values (`geom_point()`).
## Warning: Removed 3 rows containing missing values (`geom_label_repel()`).
The warriors on the other hand have most of their starters in quadrant 2 (above average defense but below average offense). This is interesting! I am curious what is really predicting the Kings’ wins if the Warriors have statistically better offensive and defensive ratings compared to the Kings through 2 games. Maybe it is really that their best players (starters) just aren’t performing as well as they should be.
warriors<- sac_gsw2 %>% filter(TEAM=="Warriors")
ggplot(warriors, aes(x=ORtg, y=DRtg, color=TEAM, size=MP)) +
geom_point(size=3)+
scale_color_manual(values = colors)+
geom_label_repel(aes(label = Player))+
geom_hline(yintercept = mean(warriors$DRtg, na.rm=T), color="blue1", linetype="dotdash", size=1)+
geom_vline(xintercept = mean(warriors$ORtg, na.rm=T), color="blue1", linetype="dotdash", size=1)
## Warning: Removed 3 rows containing missing values (`geom_point()`).
## Warning: Removed 3 rows containing missing values (`geom_label_repel()`).
after a rough 2 game stretch in San Francisco, the series is tied 2-2, effectively letting us start over. the two away games were not necessarily rough in the sense of blow outs, but were definitely winable games for the Kings. It would have been seemingly almost everything to steal a game at the Chase center (and we still could!) but are going to need to win essentially win out at home as well.
Either way, it’s still been an amazing series and the Kings have
still accomplished so much this season
for this update, I’m going to look at the “basic” statistics through 4 games. Specifically, I want to see who is over/under performing based on shooting percentages etc averaged during the season
kings4<- fread("/Users/claire/Documents/Script/kings_4games.csv", header=T, data.table=F)
warriors4<- fread("/Users/claire/Documents/Script/warriors_4games.csv", header=T, data.table=F)
the column names don’t necessarily all align… so we’ll look at 3 PT%, FT%, assists per game, turn overs per game and points per game
colnames(sac_gsw)
## [1] "RANK" "NAME" "TEAM" "POS" "AGE" "GP" "MPG" "USG%" "TO%"
## [10] "FTA" "FT%" "2PA" "2P%" "3PA" "3P%" "eFG%" "TS%" "PPG"
## [19] "RPG" "APG" "SPG" "BPG" "TPG" "P+R" "P+A" "P+R+A" "VI"
## [28] "ORtg" "DRtg" "labs"
colnames(kings4)
## [1] "Rk" "Player" "Age" "G" "GS" "MP" "FG" "FGA"
## [9] "3P" "3PA" "FT" "FTA" "TOV" "PF" "FG%" "3P%"
## [17] "FT%" "MP" "PTS" "TRB" "AST" "STL" "BLK"
kings_avg<- sac_gsw %>% filter(TEAM=="Kings") %>%
select(NAME, `FT%`, `3P%`, PPG, APG, TPG) %>%
rename(Player=NAME)%>%
mutate(Statistic="Season average")
kings_series<- kings4 %>% select(Player, `FT%`, `3P%`, PTS, AST, TOV) %>%
rename(PPG=PTS,
APG=AST,
TPG=TOV) %>%
mutate(Statistic="Series average")
head(kings_avg)
## Player FT% 3P% PPG APG TPG Statistic
## 1 De'Aaron Fox 0.780 0.325 25.0 6.1 2.5 Season average
## 2 Domantas Sabonis 0.742 0.373 19.1 7.3 2.9 Season average
## 3 Kevin Huerter 0.725 0.402 15.2 2.9 1.3 Season average
## 4 Harrison Barnes 0.847 0.374 15.0 1.6 1.0 Season average
## 5 Malik Monk 0.889 0.359 13.5 3.9 1.9 Season average
## 6 Keegan Murray 0.765 0.411 12.2 1.2 0.8 Season average
head(kings_series)
## Player FT% 3P% PPG APG TPG Statistic
## 1 De'Aaron Fox 0.700 0.342 31.5 7.0 12 Series average
## 2 Malik Monk 0.958 0.350 17.5 3.5 6 Series average
## 3 Domantas Sabonis 0.611 0.000 16.3 4.5 15 Series average
## 4 Harrison Barnes 0.692 0.250 13.0 1.0 0 Series average
## 5 Kevin Huerter 0.500 0.143 9.0 1.5 3 Series average
## 6 Davion Mitchell 1.000 0.333 8.5 2.3 4 Series average
kings_comp<- rbind(kings_avg, kings_series)
kings_comp<- kings_comp %>% group_by(Player) %>%
mutate(diff_ppg=PPG[2]-PPG[1],
diff_3P= `3P%`[2]-`3P%`[1],
diff_APG= APG[2]-APG[1],
diff_TPG=TPG[2]-TPG[1]) ### series minus season
points per game
kings_comp$color<- ifelse(kings_comp$diff_ppg>0, "green", "red")
ggplot(kings_comp, aes(x = PPG, y = reorder(Player, diff_ppg), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("forestgreen", "red"))+
geom_line() +
ggtitle("Difference in average points per game for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("Points per game")
3 point %
kings_comp$color<- ifelse(kings_comp$diff_3P>0, "green", "red")
ggplot(kings_comp, aes(x = `3P%`, y = reorder(Player, diff_3P), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("forestgreen", "red"))+
geom_line() +
ggtitle("Difference in average 3 point percentage for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("3 point percentage per game")
## Warning: Removed 3 rows containing missing values (`geom_point()`).
## Warning: Removed 3 rows containing missing values (`geom_line()`).
assists per game
kings_comp$color<- ifelse(kings_comp$diff_APG>0, "green", "red")
ggplot(kings_comp, aes(x = APG, y = reorder(Player, diff_APG), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("forestgreen", "red"))+
geom_line() +
ggtitle("Difference in average assists per game for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("Assists per game")
turnovers per game
kings_comp$color<- ifelse(kings_comp$diff_TPG>0, "green", "red")
ggplot(kings_comp, aes(x = TPG, y = reorder(Player, -diff_TPG), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("red", "forestgreen"))+
geom_line() +
ggtitle("Difference in average turnovers per game for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("Turnovers per game")
for the warriors:
warrors_avg<- sac_gsw %>% filter(TEAM=="Warriors") %>%
select(NAME, `FT%`, `3P%`, PPG, APG, TPG) %>%
rename(Player=NAME)%>%
mutate(Statistic="Season average")
warriors_series<- warriors4 %>% select(Player, `FT%`, `3P%`, PTS, AST, TOV) %>%
rename(PPG=PTS,
APG=AST,
TPG=TOV) %>%
mutate(Statistic="Series average")
warriors_comp<- rbind(warrors_avg, warriors_series)
warriors_comp<- warriors_comp %>% group_by(Player) %>%
mutate(diff_ppg=PPG[2]-PPG[1],
diff_3P= `3P%`[2]-`3P%`[1],
diff_APG= APG[2]-APG[1],
diff_TPG=TPG[2]-TPG[1]) ### series minus season
points per game
warriors_comp$color<- ifelse(warriors_comp$diff_ppg>0, "green", "red")
ggplot(warriors_comp, aes(x = PPG, y = reorder(Player, diff_ppg), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("forestgreen", "red"))+
geom_line() +
ggtitle("Difference in average points per game for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("Points per game")
3 point %
warriors_comp$color<- ifelse(warriors_comp$diff_3P>0, "green", "red")
ggplot(warriors_comp, aes(x = `3P%`, y = reorder(Player, diff_3P), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("forestgreen", "red"))+
geom_line() +
ggtitle("Difference in average 3 point percentage for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("3 point percentage per game")
## Warning: Removed 2 rows containing missing values (`geom_point()`).
## Warning: Removed 2 rows containing missing values (`geom_line()`).
assists per game
warriors_comp$color<- ifelse(warriors_comp$diff_APG>0, "green", "red")
ggplot(warriors_comp, aes(x = APG, y = reorder(Player, diff_APG), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("forestgreen", "red"))+
geom_line() +
ggtitle("Difference in average assists per game for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("Assists per game")
turnovers per game
warriors_comp$color<- ifelse(warriors_comp$diff_TPG>0, "green", "red")
ggplot(warriors_comp, aes(x = TPG, y = reorder(Player, -diff_TPG), col= factor(color), group=Player)) +
geom_point(aes(shape=Statistic)) +
scale_colour_manual(values = c("red", "forestgreen"))+
geom_line() +
ggtitle("Difference in average turnovers per game for season vs series")+
ylab("") +
guides(colour = "none")+
xlab("Turnovers per game")