Last active
December 18, 2015 15:14
-
-
Save abresler/6d1f3483fa86512d77e2 to your computer and use it in GitHub Desktop.
Quick data comb for NBA player data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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