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
summarySequenceDiagram <- function(df = mtcars, column_fill = "#05ffff", stroke_fill = "#0D3FF3", stroke_width = 1, inBrowser = TRUE){ | |
library(DiagrammeR) | |
library(dplyr) | |
if(inBrowser == T){ | |
options(viewer = NULL) | |
} | |
connections <- sapply( | |
1:ncol(df) | |
, function(i){ | |
paste0( |
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
#http://rpubs.com/bradleyboehmke/median_income_trends | |
# Preprocessing & summarizing data | |
library(dplyr) | |
library(tidyr) | |
library(RCurl) | |
library(XLConnect) | |
library(magrittr) | |
appURL <- "https://www.census.gov/hhes/www/income/data/historical/household/2013/h08.xls" | |
f = CFILE("exfile.xls", mode="wb") | |
curlPerform(url = appURL, writedata = f@ref, ssl.verifypeer = FALSE) |
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
library("ggthemes") | |
c("randomForest","dplyr","magrittr","ggplot2","ggthemes") -> packages | |
lapply(packages,library, character.only = TRUE) | |
getBREFTeamStatTable <- function(season_end = 2015, table_name = 'team', date = T){ | |
c('rvest','dplyr','pipeR','RCurl', 'XML','reshape2') -> packages | |
lapply(packages, library, character.only = T) | |
'http://www.basketball-reference.com/leagues/' -> base | |
(season_end-1) %>>% paste0("-",season_end) -> season | |
'NBA' -> league | |
table_name %>>% tolower -> table_name |
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 34 columns, instead of 5 in line 4.
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
name.table,id.season,is.offense,name.player,team,id.player,jersey,id.position,id.team,slug.team,city.team,gp,possesions,pct.play_type,pts,fga,fgm,ppp,ppp.worse,ppp.better,possesions.per_game,pts.per_game,fga.per_game,fgm.per_game,fg.miss.per_game,rank,pct.fg,pct.efg,pct.ft_achieved,pct.to,pct.shooting_foul,pct.and_1,pct.scored,stem.table | |
Post-Up,2015-16,TRUE,Paul Millsap,Atlanta Hawks,200794,4,F,1610612737,ATL,Atlanta,4,13,19.69700050354,20,8,7,1.53846001625061,25,0,3.25,5,2,1.75,0.25,1,87.5,87.5,30.7692307692308,15.3846153846154,30.7692307692308,7.69230769230769,76.9230769230769,Postup | |
Post-Up,2015-16,TRUE,Al Horford,Atlanta Hawks,201143,15,F-C,1610612737,ATL,Atlanta,4,11,15.0684995651245,12,8,6,1.09090995788574,17,7,2.75,3,2,1.5,0.5,2,75,75,0,27.2727272727273,0,0,54.5454545454545,Postup | |
Post-Up,2015-16,FALSE,Kent Bazemore,Atlanta Hawks,203145,24,G,1610612737,ATL,Atlanta,4,11,22.917,7,7,1,0.636,5,4,2.75,1.75,1.75,0.25,1.5,6,14.286,14.286,27.273,9.091,27.273,0,36.364,Postup | |
Post-Up,2015-16,FALSE,Al Horford,A |
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 <- #need all of these installed including some from github | |
c('dplyr', | |
'magrittr', | |
'jsonlite', | |
'tidyr', | |
'stringr', | |
'lubridate') | |
options(warn = -1) | |
lapply(packages, library, character.only = T) |
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
#' Get's NBA player's season shot chart with specific parameters | |
#' | |
#' @param player | |
#' @param year_season_end | |
#' @param plot_hex | |
#' @param author | |
#' @param use_shot_zone_side | |
#' @param season_type | |
#' @param shot_areas | |
#' @param shot_types |
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
#' Gets NBA team Bokeh Shot Chart | |
#' | |
#' @param team can be = #c("76ers", "Bucks", "Bulls", "Cavaliers", "Celtics", "Clippers", | |
#"Grizzlies", "Hawks", "Heat", "Hornets", "Jazz", "Kings", "Knicks", | |
#"Lakers", "Magic", "Mavericks", "Nets", "Nuggets", "Pacers", | |
#"Pelicans", "Pistons", "Raptors", "Rockets", "Spurs", "Suns", | |
#"Thunder", "Timberwolves", "Trail Blazers", "Warriors", "Wizards") | |
#' @param year_roster - year of the roster | |
#' @param year_data | |
#' @param plot_hex - T or F, shows |
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
library(DiagrammeR) | |
library(magrittr) | |
library(visNetwork) | |
moments <- | |
'https://gist.githubusercontent.com/rich-iannone/9c4e50cd5d811b841349/raw/65bc97ddac2f9e52a4252fcf2060007fe1afeb7d/moment.csv' %>% | |
read_csv() | |
# Generate the court | |
court <- |
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 <- #need all of these installed including some from github | |
c( | |
'dplyr', | |
'magrittr', | |
'jsonlite', | |
'tidyr', | |
'stringr', | |
'lubridate', | |
'stringr', | |
'tidyr' |
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
devtools::install_github("abresler/nbastatR") | |
devtools::install_github("hadley/purrr") | |
games <- | |
nbastatR::get_days_games(date = "11-30-2015") | |
all_days_gamelogs <- | |
games$id.game %>% | |
purrr::map(function(x) | |
nbastatR::get_games_ids_box_score_tables(game_id = x, | |
tables = c('Traditional', 'Usage', |