在知乎看到的问题,来回答一波
首先我们定义一下什么是攻防一体,在前面的回答中有答主采用的标准是——全明星球员并且入选最佳防守阵容。本篇文章采用的标准是:
- 每36分钟得分(Points)、盖帽(Blocks)、抢断(Steals)均排在所有得分后卫球员的前50%
- 进攻赢球贡献值(Offensive Win Shares)和防守赢球贡献值(Defensive Win Shares)也得排在所有得分后卫的前50%。
接下来使用R语言的ballr包中的函数抓取2018赛季所有球员的统计数据
- NBAPerGameAdvStatistics(season = 2018) 函数抓取2018赛季所有球员的高阶统计数据,这里我们用到的包括进攻赢球贡献值和防守赢球贡献值。
- NBAPerGameStatisticsPer36Min(season = 2018) 函数抓取2018赛季所有球员的常规统计数据,这里我们用到的是每36分钟得分,盖帽,和抢断
代码
library(ballr)
help(package="ballr")
players1 <- NBAPerGameStatisticsPer36Min(season = 2018)
players2 <- NBAPerGameAdvStatistics(season = 2018)
dim(players1)
dim(players2)
可以看到2018赛季NBA总共有664名球员有统计数据。
接下来把我们需要的数据整理到一个数据框里
which(players1$player != players2$player)
df<-data.frame(player=players1$player, tm=players1$tm,
pos=players1$pos, blk=players1$blk,
stl=players1$stl, ows=players2$ows,
dws=players2$dws, pts=players1$pts)
table(df$pos)
C PF PG PG-SG SF SF-SG SG
126 122 142 1 115 2 156
根据以上结果可以看出2018赛季总共有156名得分后卫有统计数据,还有3名球员会出现在2个不同的位置上,这三个人分别是
(做这一步的时候发现一个问题:并不能根据数据有多少行就说有多少名球员,如果有的球员中间换队的话,会被统计两次)
> df%>%
+ filter(pos %in% c("SF-SG"))
player tm pos blk stl ows dws pts
1 Corey Brewer TOT SF-SG 0.4 2.4 0.7 1.6 11.3
2 Shabazz Muhammad TOT SF-SG 0.3 0.8 0.5 0.2 18.4
> df%>%
+ filter(pos %in% c("PG-SG"))
player tm pos blk stl ows dws pts
1 Isaiah Canaan TOT PG-SG 0.1 1.4 0.5 0.1 14.7
-
Corey Brewer
image.png
看名字没有认出来,但是看到图片上温暖的笑容就知道了是连长布鲁尔
-
Shabazz Muhammad
image.png
这个人也有印象,但是想不起来有什么鲜明的特征了
-
Isaiah Canaan
image.png
这个人脸熟
接下来根据我们开篇制定的标准进行筛选
> df1<-df%>%
+ filter(pos %in% c("SG"),
+ pts >= quantile(pts,probs=0.5),
+ stl >= quantile(stl,probs = 0.5),
+ blk >= quantile(blk,probs = 0.5),
+ ows >= quantile(ows, probs = 0.5),
+ dws >= quantile(dws, probs = 0.5))
> df1
player tm pos blk stl ows dws pts
1 Will Barton DEN SG 0.7 1.1 4.4 1.8 17.0
2 James Harden HOU SG 0.7 1.8 11.6 3.8 30.9
3 Jrue Holiday NOP SG 0.8 1.5 4.2 2.9 18.9
4 Jeremy Lamb CHO SG 0.6 1.1 3.0 1.9 18.9
5 Victor Oladipo IND SG 0.8 2.5 4.3 4.0 24.5
6 Dwyane Wade CLE SG 1.1 1.4 0.4 0.9 17.3
通过以上标准的有6个人,分别是
-
掘金队的巴顿
image.png
-
火箭队的哈登
image.png
-
鹈鹕队的霍乐迪
image.png
-
公牛队的这个人的名字我还真叫不上来
image.png
-
步行者队的奥拉迪波
image.png
-
骑士时期的韦德
image.png
接下来对各个统计指标通过柱形图进行可视化展示
library(ggplot2)
ggplot(df1,aes(x=reorder(player,pts),y=pts))+
geom_col(aes(fill=player))+
geom_text(aes(label=pts),hjust=-0.5)+
coord_flip()+ylim(0,35)+
theme_bw()+labs(x="",y="Points Per 36 Minutes")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,stl),y=stl))+
geom_col(aes(fill=player))+
geom_text(aes(label=stl),hjust=-0.5)+
coord_flip()+ylim(0,3)+
theme_bw()+labs(x="",y="Steals")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,blk),y=blk))+
geom_col(aes(fill=player))+
geom_text(aes(label=blk),hjust=-0.5)+
coord_flip()+ylim(0,1.5)+
theme_bw()+labs(x="",y="Blocks")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,ows),y=ows))+
geom_col(aes(fill=player))+
geom_text(aes(label=ows),hjust=-0.5)+
coord_flip()+ylim(0,12.5)+
theme_bw()+labs(x="",y="Offensive Win Shares")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,dws),y=dws))+
geom_col(aes(fill=player))+
geom_text(aes(label=dws),hjust=-0.5)+
coord_flip()+ylim(0,5)+
theme_bw()+labs(x="",y="Densive Win Shares")+
theme(legend.position = "none")
-
得分
image.png
哈登遥领先
-
抢断
image.png
奥拉迪波第一名
-
盖帽
image.png
韦德,得分后卫中的盖帽王
-
进攻赢球贡献值
image.png
哈登依旧遥遥领先
-
防守赢球贡献值
image.png
奥拉迪波第一名,哈登紧随其后。
综上所述,2018赛季的哈登攻防两端皆由出色的表现,带领火箭队在西部决赛中惜败当年的总冠军勇士队,MVP称号实至名归!
完整代码
library(ballr)
help(package="ballr")
players1 <- NBAPerGameStatisticsPer36Min(season = 2018)
players2 <- NBAPerGameAdvStatistics(season = 2018)
dim(players1)
dim(players2)
which(players1$player != players2$player)
df<-data.frame(player=players1$player, tm=players1$tm,
pos=players1$pos, blk=players1$blk,
stl=players1$stl, ows=players2$ows,
dws=players2$dws, pts=players1$pts)
table(df$pos)
library(dplyr)
df%>%
filter(pos %in% c("PG-SG"))
df%>%
filter(pos %in% c("SF-SG"))
df1<-df%>%
filter(pos %in% c("SG"),
pts >= quantile(pts,probs=0.5),
stl >= quantile(stl,probs = 0.5),
blk >= quantile(blk,probs = 0.5),
ows >= quantile(ows, probs = 0.5),
dws >= quantile(dws, probs = 0.5))
df1
library(ggplot2)
ggplot(df1,aes(x=reorder(player,pts),y=pts))+
geom_col(aes(fill=player))+
geom_text(aes(label=pts),hjust=-0.5)+
coord_flip()+ylim(0,35)+
theme_bw()+labs(x="",y="Points Per 36 Minutes")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,stl),y=stl))+
geom_col(aes(fill=player))+
geom_text(aes(label=stl),hjust=-0.5)+
coord_flip()+ylim(0,3)+
theme_bw()+labs(x="",y="Steals")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,blk),y=blk))+
geom_col(aes(fill=player))+
geom_text(aes(label=blk),hjust=-0.5)+
coord_flip()+ylim(0,1.5)+
theme_bw()+labs(x="",y="Blocks")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,ows),y=ows))+
geom_col(aes(fill=player))+
geom_text(aes(label=ows),hjust=-0.5)+
coord_flip()+ylim(0,12.5)+
theme_bw()+labs(x="",y="Offensive Win Shares")+
theme(legend.position = "none")
ggplot(df1,aes(x=reorder(player,dws),y=dws))+
geom_col(aes(fill=player))+
geom_text(aes(label=dws),hjust=-0.5)+
coord_flip()+ylim(0,5)+
theme_bw()+labs(x="",y="Densive Win Shares")+
theme(legend.position = "none")
欢迎大家关注我的公众号小明的数据分析笔记本

网友评论