Skip to content

Instantly share code, notes, and snippets.

@Sandy4321
Sandy4321 / xy_plot_example.r
Created December 18, 2015 15:12 — forked from abresler/xy_plot_example.r
XY ggplot using nbastatR
library("devtools")
install_github(c("hadley/ggplot2", "jrnold/ggthemes", "abresler/nbastatR"))
packages <-
c('nbastatR', 'dplyr', 'magrittr', 'ggthemes', 'ggplot2')
lapply(packages, library, character.only = T)
teams2015 <-
get_all_team_traditional_stat_tables(year.season_start = 2015)
@Sandy4321
Sandy4321 / nets_make_me_cry_code.r
Created December 18, 2015 15:13 — forked from abresler/nets_make_me_cry_code.r
Nets FGA/FGM 4th Quarter Code
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"
)
) %>%
period name.player id.position fgm fga
Q1 Andrea Bargnani PF 2 6
Q1 Bojan Bogdanovic SF 6 9
Q1 Brook Lopez C 11 18
Q1 Donald Sloan PG 0 2
Q1 Jarrett Jack PG 6 15
Q1 Joe Johnson SF 5 11
Q1 Markel Brown SG 2 4
Q1 Rondae Hollis-Jefferson SF 2 3
Q1 Shane Larkin PG 2 7
@Sandy4321
Sandy4321 / get_nba_players_ids.r
Created December 18, 2015 15:13 — forked from abresler/get_nba_players_ids.r
Gets list of NBA players
packages <- #need all of these installed including some from github
c('dplyr',
'magrittr',
'jsonlite',
'tidyr',
'stringr',
'data.table',
'tidyr')
options(warn = -1)
lapply(packages, library, character.only = T)
@Sandy4321
Sandy4321 / world-cities-diagrammer.R
Created December 18, 2015 15:13 — forked from abresler/world-cities-diagrammer.R
Demonstration code for plotting a graph of world cities along with country borders with the DiagrammeR R package.
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create a graph of border coordinates
country_graph <- country_graph()
# Read in a CSV with location and population data for cities all over the world
#' GET NBA PLAYER SHOT DETAIL DATA
#'
#' @param player
#' @param year_season_end
#' @param use_shot_zone_side
#' @param season_type
#' @param shot_types
#' @param shot_areas
#' @param vs_conference
#' @param vs_division
packages <- #need all of these installed including some from github
c(
'dplyr',
'magrittr',
'jsonlite',
'tidyr',
'stringr',
'tidyr'
)
options(warn = -1)
@Sandy4321
Sandy4321 / neuralnetR.R
Created December 18, 2015 15:14 — forked from abresler/neuralnetR.R
A neural network exaple in R. Full article at:
# Set a seed
set.seed(500)
library(MASS)
data <- Boston
# Check that no data is missing
apply(data,2,function(x) sum(is.na(x)))
# Train-test random splitting for linear model
@Sandy4321
Sandy4321 / plot_player_shot_chart.r
Created December 18, 2015 15:15 — forked from abresler/plot_player_shot_chart.r
R function to auto generate heat map shot charts, need help completing court drawing then to complete
#' NBA Player Shot Chart
#'
#' @param player name the player, must be exact
#' @param author, year_end_season: numeric end of season
#'
#' @return
#' @export
#'
#' @examples boggie_bog <- plot_player_shot_chart(player = "Bojan Bogdanovic",
#year_season_end = 2015, exclude_backcourt = T
@Sandy4321
Sandy4321 / jea
Created December 18, 2015 15:15 — forked from abresler/jea
basic_ocr_extraction
"x"
"1" "5r Amendments: lf(i) the Company receives a Partial Loan Increase (ii) the Company does not receive a Commitment prior to the Outside Date or (iii) a Failure to Close occurs, then the Current Agreement shall automatically be amended as of the Closing Date (in the case ofa Partial Loan Increase), the Outside Date (in the case ofa failure to receive a Commitment) or the funding ofthe Balance Payment (in the case ofa Failure to Close), as applicable, by deleting Section 8.2 ofthe Current Agreement in its entirety and replacing it with the following: “Section 8.2 Distributions ofNet Cash Plow and Capital Proceeds. All Net Cash Flow and all Capital Proceeds shall be distributed in the following order of priority: .(a) m, l00% to the Carlyle Member andthe HFZ Member, pro rata in accordance with their Capital Sharing Ratios, until thc Carlyle Member has received distributions sufficient to achieve an Internal Rate of Return on its Capital Contributions equal to |2%; then (b) Second, (i) 85% to the Carlyle M