Skip to content

Instantly share code, notes, and snippets.

@batpigandme
batpigandme / stattle_nba_point_leads_sm_multiples.R
Last active January 29, 2016 15:23
Different ways of visualizing team point leads and outcomes using small multiples.
## visualize team point leads and outcomes with small multiples
## install and load ggplot2
install.packages("ggplot2")
library(ggplot2)
## make separate point plots for each team
ggplot(teamgame_point_leads, aes(x=final_point_diff, y=points_biggest_lead)) + geom_point() +
facet_wrap(~team_slug)
@batpigandme
batpigandme / steph_curry_3ptpct_densityplot.R
Created February 24, 2016 18:37
Make a density plot of Steph Curry's three point percentages so far this season by game.
d3pct <- density(steph_gls$three_pointers_pct)
plot(d3pct)
@batpigandme
batpigandme / curry_three_pointers_base_ggplot.R
Last active February 25, 2016 15:14
EDA with density plot and histograms of nba-stephen-curry three point shooting, base R, and with ggplot2 and ggthemes
## steph curry's three-point shooting data from
## stattleship api
## density plot of three-pt pctg
d <- density(steph_gls$three_pointers_pct)
plot(d, type="n", main="three point percentage")
polygon(d, col="red", border="gray")
## histograms
hist(steph_gls$three_pointers_attempted)
@batpigandme
batpigandme / summary_threes_curry_gls.txt
Last active February 25, 2016 16:33
nba-stephen-curry summary of three point stats
│ three_pointers_attempted │ three_pointers_made │ three_pointers_pct │
├──────────────────────────┼─────────────────────┼────────────────────┤
│ Min. : 4.00 │ Min. : 1.000 │ Min. :0.1110 │
│ 1st Qu.: 9.00 │ 1st Qu.: 3.000 │ 1st Qu.:0.3407 │
│ Median :11.00 │ Median : 5.000 │ Median :0.4550 │
│ Mean :10.81 │ Mean : 4.926 │ Mean :0.4401 │
│ 3rd Qu.:13.00 │ 3rd Qu.: 7.000 │ 3rd Qu.:0.5000 │
│ Max. :16.00 │ Max. :11.000 │ Max. :0.7330 │
@batpigandme
batpigandme / steph_gls_stattleship_retrieval.R
Last active August 29, 2016 13:01
Retrieve nba-stephen-curry game logs from stattleship API.
## install and load the stattleshipR package
devtools::install_github("stattleship/stattleship-r")
library(stattleshipR)
## optional: load dplyr
library(dplyr)
## get your API token stattleship.com
## set API token
set_token('YOUR API TOKEN')
@batpigandme
batpigandme / nba1617_preseason_team_summary.R
Last active October 25, 2016 20:39
Get summary statistics for each NBA team in the 2016-17 NBA season
##################################
## Getting Team Preseason Stats ##
##################################
## set strings as factors to false
options(stringsAsFactors = FALSE)
## load libraries
library(stattleshipR)
library(dtplyr)
@batpigandme
batpigandme / visdat_review.md
Last active January 24, 2017 13:14
Copy of ropensci reviewer template for use in reviewing package. Original source: https://github.com/ropensci/onboarding/blob/master/reviewer_template.md

Package Review

Please check off boxes as applicable, and elaborate in comments below. Your review is not limited to these topics, as described in the reviewer guide

  • As the reviewer I confirm that there are no conflicts of interest for me to review this work (such as being a major contributor to the software).

Documentation

The package includes all the following forms of documentation:

Keybase proof

I hereby claim:

  • I am batpigandme on github.
  • I am maraaverick (https://keybase.io/maraaverick) on keybase.
  • I have a public key ASBGZYlMVMOAmXm5NnWjniIDny002jlVi144EAtWkvcz9wo

To claim this, I am signing this object:

@batpigandme
batpigandme / string_elt_error.txt
Created March 12, 2017 13:15
NULL character vector error in classic_you 2017-03-12
Error in mutate_impl(.data, dots) : STRING_ELT() can only be applied to a 'character vector', not a 'NULL'
26.
mutate_impl(.data, dots)
25.
mutate.tbl_df(., instance = row_number(term))
24.
mutate(., instance = row_number(term))
23.
function_list[[1L]](value)
22.
@batpigandme
batpigandme / nbastatR_error.txt
Created March 28, 2017 18:19
Getting this when I run: devtools::install_github("abresler/nbastatR")
* installing *source* package ‘nbastatR’ ...
** R
** tests
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘curlconverter’
ERROR: lazy loading failed for package ‘nbastatR’
* removing ‘/Users/maraaverick/Library/R/3.3/library/nbastatR’
Error: Command failed (1)