※ 当サイトは、アフィリエイト広告を利用しています。

データで見るサンアントニオ・スパーズの特徴と傾向【NBA2021-22 レギュラー・シーズン】

記事内に広告が含まれています。
スポンサーリンク

※参考<統計ソフトRに入力するコマンド>

 統計ソフトRのインストール手順をまとめた記事も作成していますので、よろしければご参考ください。

library(BasketballAnalyzeR)
library(gridExtra)
library(dplyr)
Pbox2122 <- read.csv(file="Pbox_2122.csv")
dts.PbP.2122 <- read.csv(file="PbP_2122.csv")
PbP2122 <- PbPmanipulation(dts.PbP.2122)

# Bubble plot of the players
Pbox2122b <- subset(Pbox2122, MIN>=500)
data2122b <- subset(Pbox2122b, Team=="San Antonio Spurs")
attach(data2122b)
X2 <- data.frame(P=Player, P2M=P2M/GP, P3M=P3M/GP, FTp, AS=(P2A+P3A+FTA)/GP)
detach(data2122b)
labs1 <- c("2-point shots made per Game", "3-point shots made per Game", "free throws (% made)", "Total shots attempted per Game")
bubbleplot(X2, id="P", x="P2M", y="P3M", col="FTp", size="AS", labels=labs1, title="Bubble plot of San Antonio Spurs' players: Shooting stats and shots attempted (NBA 2021 - 2022 Regular season)", text.size=3.5, mx = mean(Pbox2122b$P2M/Pbox2122b$GP), my = mean(Pbox2122b$P3M/Pbox2122b$GP))

attach(data2122b)
Y2 <- data.frame(P=Player, DREB=DREB/GP, STL=STL/GP, BLK=BLK/GP, PM=PM/GP)
detach(data2122b)
labs2 <- c("Defensive Rebounds per Game", "Blocks per Game", "Plus-Minus per Game", "Steals per Game")
bubbleplot(Y2, id="P", x="DREB", y="BLK", col="PM", size="STL", labels=labs2, title="Bubble plot of San Antonio Spurs' players: Defensive stats and Plus-Minus (NBA 2021 - 2022 Regular season)", text.size=3.5, mx = mean(Pbox2122b$DREB/Pbox2122b$GP), my = mean(Pbox2122b$BLK/Pbox2122b$GP))

# Radar chart of the players
Pbox2122r <- subset(Pbox2122, MIN>=500)
attach(Pbox2122r)
T <- data.frame(P2M,P3M, FTM, REB=OREB+DREB, AST, STL, BLK)/MIN
detach(Pbox2122r)
T2 <- data.frame(Team=Pbox2122r$Team, Player=Pbox2122r$Player, T)
listplots <- radialprofile(data=T2[3:9], title=T2$Player, std=TRUE)
listplotsT <- listplots[T2$Team=="San Antonio Spurs"]
grid.arrange(grobs=listplotsT[1:15], ncol=5)

# Variability diagram of the traditional stats
Pbox2122v <- subset(Pbox2122, Team=="San Antonio Spurs" & MIN>=500)
vrb <- variability(data=Pbox2122v, data.var=c("P2M", "P3M", "FTM", "OREB", "DREB","AST","STL","BLK","TOV"), size.var=c("MIN"))
plot(vrb, title="Variability diagram of the traditional stats, San Antonio Spurs' players (NBA 2021 - 2022 Regular season)")

# Shot chart of the team
PbP2122sc <- subset(PbP2122, data_set!="2021-22 Playoffs" & team=="SAS")
PbP2122sc$xx <- PbP2122sc$original_x/-10
PbP2122sc$yy <- PbP2122sc$original_y/10-41.75
shotchart(data=PbP2122sc, x="xx", y="yy", z="playlength", num.sect=5, type="sectors", scatter=FALSE, result="result")
shotchart(data=PbP2122sc, x="xx", y="yy", type="density-hexbin", nbins=50, palette="bwr")

# Density estimation of the field shots
data2122d <- subset(PbP2122, data_set!="2021-22 Playoffs" & result!="" & shot_distance!="" & team=="SAS")
densityplot(data=data2122d, shot.type="field", var="shot_distance", best.score=TRUE, title="Density estimation of the field shots of San Antonio Spurs, with respect to shot distance (NBA 2021 - 2022 Regular Season)")
densityplot(data=data2122d, shot.type="field", var="totalTime", best.score=TRUE, title="Density estimation of the field shots of San Antonio Spurs, with respect to total time (NBA 2021 - 2022 Regular Season)")
densityplot(data=data2122d, shot.type="field", var="playlength", best.score=TRUE, title="Density estimation of the field shots of San Antonio Spurs, with respect to play length (NBA 2021 - 2022 Regular Season)")

# Expected points of the teams
data2122t <- subset(PbP2122, data_set!="2021-22 Playoffs" & result!="" & shot_distance!="" & team=="SAS")
data2122o <- subset(PbP2122, data_set!="2021-22 Playoffs" & result!="" & shot_distance!="" & oppTeam=="SAS")
data2122t <- mutate(data2122t, player = "San Antonio Spurs")
data2122o <- mutate(data2122o, player = "Opponent teams")
data2122TO <- bind_rows(data2122t, data2122o)
pl <- c("San Antonio Spurs","Opponent teams")
mypal <- colorRampPalette(c("purple","red","red"))
expectedpts(data2122TO, players=pl, col.team="gray", palette=mypal, col.hline="transparent", var="shot_distance", xlab="Shot distance", title="Expected points of San Antonio Spurs and opponent teams, with respect to shot distance (NBA 2021 - 2022 Regular Season)")
expectedpts(data2122TO, bw=1500, players=pl, col.team="gray", palette=mypal, col.hline="transparent", var="totalTime", xlab="Total time", title="Expected points of San Antonio Spurs and opponent teams, with respect to total time (NBA 2021 - 2022 Regular Season)")
expectedpts(data2122TO, players=pl, col.team="gray", palette=mypal, col.hline="transparent", var="playlength", xlab="Play length", title="Expected points of San Antonio Spurs and opponent teams, with respect to play length (NBA 2021 - 2022 Regular Season)")

# Network of assists
PbP2122an <- subset(PbP2122, team=="SAS")
PbP2122AN <- PbP2122an[!(PbP2122an$event_type=="shot" & PbP2122an$result=="missed"),]
netdataAN <- assistnet(PbP2122AN)
plot(netdataAN, layout="circle", edge.thr=20, node.col="FGPTS", node.size="ASTPTS")
TABan <- netdataAN$assistTable
Xan <- netdataAN$nodeStats
names(Xan)[1] <- "Player"
dataAN <- merge(Xan, Pbox2122, by="Player")
dataANsp <- subset(dataAN, Team=="San Antonio Spurs")
mypal <- colorRampPalette(c("blue", "yellow", "red"))
scatterplot(dataANsp, data.var=c("ASTPTS", "FGPTS"), z.var="MIN", labels=dataANsp$Player, palette=mypal, repel_labels=TRUE, title="Scatter plot of San Antonio Spurs' players: ASTPTS and FGPTS (NBA 2021 - 2022 Regular Season)")
selan <- which(dataAN$MIN>1500 & dataAN$Team=="San Antonio Spurs")
tabAN <- TABan[selan, selan]
no.pl <- nrow(tabAN)
pR <- pM <- vector(no.pl, mode="list")
GiniM <- array(NA, no.pl)
GiniR <- array(NA, no.pl)
for (pl in 1:no.pl){
      ineqplM <- inequality(tabAN[pl,], npl=no.pl)
      GiniM[pl] <- ineqplM$Gini
      ineqplR <- inequality(tabAN[,pl], npl=no.pl)
      GiniR[pl] <- ineqplR$Gini
      title <- rownames(tabAN)[pl]
      pM[[pl]] <- plot(ineqplM, title=title)
      pR[[pl]] <- plot(ineqplR, title=title)
      }

grid.arrange(grobs=pM, nrow=2)
grid.arrange(grobs=pR, nrow=2)

# Shot chart of the opponent teams
PbP2122sco <- subset(PbP2122, data_set!="2021-22 Playoffs" & oppTeam=="SAS")
PbP2122sco$xx <- PbP2122sco$original_x/-10
PbP2122sco$yy <- PbP2122sco$original_y/10-41.75
shotchart(data=PbP2122sco, x="xx", y="yy", z="playlength", num.sect=5, type="sectors", scatter=FALSE, result="result")
shotchart(data=PbP2122sco, x="xx", y="yy", type="density-hexbin", nbins=50, palette="bwr")

# Density estimation of the field shots of the opponent teams
data2122do <- subset(PbP2122, data_set!="2021-22 Playoffs" & result!="" & shot_distance!="" & oppTeam=="SAS")
densityplot(data=data2122do, shot.type="field", var="shot_distance", best.score=TRUE, title="Density estimation of field shots of San Antonio Spurs' opponents, with respect to shot distance (NBA 2021 - 2022 Regular Season)")

⇐ 2020-21 |🏀| 2022-23 ⇒

※データ分析を実践する際に参考にしている書籍『Basketball Data Science: With Applications in R』の紹介記事も書いていますので、よろしければ下記よりご確認ください。

タイトルとURLをコピーしました