Skip to content

Instantly share code, notes, and snippets.

@abresler
Last active December 18, 2015 15:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save abresler/6d1f3483fa86512d77e2 to your computer and use it in GitHub Desktop.
Save abresler/6d1f3483fa86512d77e2 to your computer and use it in GitHub Desktop.
Quick data comb for NBA player data
source(
"https://gist.githubusercontent.com/abresler/bc5c6d8753bac661415e/raw/a9cde8afae83777f4fa32d1ac978e843f8398ee0/nba_player_data.r"
)
devtools::install_github('cmpolis/datacomb', subdir = 'pkg')
packages <-
c('datacomb', 'dplyr', 'htmlwidgets', 'magrittr')
lapply(packages, library, character.only = T)
data <-
get_bref_season_player_stats(
year_end_season = 2015, #can pick whatever season you want!!
stat_type = c('Per Game'), #can pick Totals, Per Game, Per Minute, or Advanced
use_traded_player_team_total = T
)
plot_data <-
data %>%
select(
player,
pos,
tm,
age,
is.traded_player,
g,
gs,
mp,
pts,
ast,
tov,
blk,
fg.,
x3p.1,
orb,
drb,
stl,
tov,
blk
) %>%
rename(traded = is.traded_player,
`3pt_pct` = x3p.1,
fg_pct = fg.)
plot_data %>%
Datacomb(rowLabel = "player",
columns = plot_data %>% select(-player) %>% names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment