-
-
Save Sandy4321/a00d853f995448f8dc93 to your computer and use it in GitHub Desktop.
Nets FGA/FGM 4th Quarter Code
This file contains hidden or 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
packages <- c('dplyr','purrr','magrittr','tidyr', 'ggplot2', 'stringr', 'jsonlite', 'ggthemes') | |
lapply(packages, library, character.only = T) | |
library(nbastatR) #devtools::install_github("abresler/nbastatR") | |
byQuarter <- | |
1:4 %>% | |
purrr::map(function(x) get_nba_traditional_player_season_stat_table(period = x, | |
per_mode = "Totals" | |
) | |
) %>% | |
compact %>% | |
bind_rows | |
nets <- | |
byQuarter %>% | |
dplyr::filter(slug.team == "BKN") | |
players_profiles <- nets$id.player %>% unique %>% | |
map(function(x) get_player_profile(id.player = x)) %>% | |
compact %>% | |
bind_rows() | |
nets %<>% | |
left_join(data_frame(name.player = c("Andrea Bargnani", "Bojan Bogdanovic", "Brook Lopez", "Donald Sloan", | |
"Jarrett Jack", "Joe Johnson", "Markel Brown", "Rondae Hollis-Jefferson", | |
"Shane Larkin", "Thaddeus Young", "Thomas Robinson", "Wayne Ellington", | |
"Sergey Karasev"), | |
id.position = c("PF", "SF", "C", "PG", | |
"PG", "SF", "SG", "SF", | |
"PG", "PF", "PF", "SG", | |
"SG"))) | |
nets %<>% | |
mutate(period = period %>% paste0("Q", .) %>% factor(ordered = T)) | |
nets %>% | |
dplyr::select(period, fga, fgm, id.position, name.player) %>% | |
gather(type, value, -c(period,id.position,name.player)) %>% | |
ggplot(aes(x = period, y = value, color = id.position, label = name.player)) + | |
facet_wrap(~type) + | |
geom_text(check_overlap = T,size = 2.5) + | |
geom_rug(position='jitter', side = 'l')+ | |
scale_colour_colorblind() + | |
theme_few() + | |
xlab("") + | |
ylab("FGA/FGM") + | |
ggtitle("Nets FG Distribution by Quarter [through 11-05-2015]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment