Skip to content

Instantly share code, notes, and snippets.

View seanjtaylor's full-sized avatar

Sean J. Taylor seanjtaylor

View GitHub Profile
library(rvest)
library(dplyr)
library(stringr)
library(ggplot2)
tbls <- read_html('https://en.wikipedia.org/wiki/List_of_serial_killers_by_number_of_victims') %>% html_table()
t1 <- tbls[[1]] %>% select(name = Name, country = Country, years = `Years active`, victims = `Proven victims`) %>% mutate(victims = as.character(victims))
t2 <- tbls[[2]] %>% select(name = Name, country = Country, years = `Years active`, victims = `Proven victims`)
library(rvest)
library(dplyr)
html.doc <- read_html('http://www.footballoutsiders.com/stat-analysis/2016/quarterbacks-and-progression-air-yards')
# Extract table
raw.table <- html.doc %>%
html_table() %>%
first
@seanjtaylor
seanjtaylor / btl.R
Last active November 15, 2016 18:16
Simple ridge regression team ranking
library(dplyr)
library(tidyr)
## 2015 season only
g2015 <- game %>%
select(seas, wk, ptsh, ptsv, h, v) %>%
filter(seas == 2015) %>%
arrange(gid)
## Makes a 32-column matrix with indicators for home team
@seanjtaylor
seanjtaylor / setuptools.md
Created January 11, 2017 18:51
Problem with setuptools

In my setup.py build command, I create a pickle file that I'd like to be available at runtime. I do this by subclassing from the setuptools.command.build_py.build_py and overriding the run command:

class my_command(build_py):
    def run(self):
        target_dir = os.path.join(self.build_lib, 'my_package/data')
        self.mkpath(target_dir)
        with open(os.path.join(target_dir, 'my_file.pkl'), 'wb') as f:
 pickle.dump({'foo': 'bar'}, f)
@seanjtaylor
seanjtaylor / wikipedia.R
Created January 12, 2017 23:08
Download a list of page views for Wikipedia back to 2008.
library(dplyr)
library(RJSONIO)
get_page_visits <- function(page) {
past <- expand.grid(year = 2008:2015, month = 1:12) %>%
mutate(url = paste('http://stats.grok.se/json/en', as.character(year * 100 + month), page, sep = '/')) %>%
group_by(url) %>%
do({
a <- RJSONIO::fromJSON(.$url)$daily_views
data_frame(ds = names(a), views = a)
@seanjtaylor
seanjtaylor / install.libs.R
Created January 24, 2017 18:38
My install.libs.R
packageStartupMessage('Compiling models (this will take a minute...)')
dest <- file.path(R_PACKAGE_DIR, paste0('libs', R_ARCH))
dir.create(dest, recursive = TRUE, showWarnings = FALSE)
logistic.growth.src <- file.path(R_PACKAGE_SOURCE, 'inst', 'stan', 'prophet_logistic_growth.stan')
logistic.growth.binary <- file.path(dest, 'prophet_logistic_growth.RData')
logistic.growth.stanc <- rstan::stanc(logistic.growth.src)
logistic.growth.stanm <- rstan::stan_model(stanc_ret = logistic.growth.stanc,
model_name = 'logistic_growth')
@seanjtaylor
seanjtaylor / check.log
Created January 24, 2017 18:46
Biarch: true + configure.win
* using log directory 'd:/RCompile/CRANguest/R-release/prophet.Rcheck'
* using R version 3.3.2 (2016-10-31)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'prophet/DESCRIPTION' ... OK
* this is package 'prophet' version '0.1'
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Sean Taylor <[email protected]>'
New submission
@seanjtaylor
seanjtaylor / check.log
Created January 24, 2017 19:41
No Biarch, No configure.win
* using log directory 'd:/RCompile/CRANguest/R-release/prophet.Rcheck'
* using R version 3.3.2 (2016-10-31)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'prophet/DESCRIPTION' ... OK
* this is package 'prophet' version '0.1'
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Sean Taylor <[email protected]>'
New submission
@seanjtaylor
seanjtaylor / check.log
Last active January 24, 2017 19:56
Biarch: true
* using log directory 'd:/RCompile/CRANguest/R-release/prophet.Rcheck'
* using R version 3.3.2 (2016-10-31)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'prophet/DESCRIPTION' ... OK
* this is package 'prophet' version '0.1'
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Sean Taylor <[email protected]>'
New submission
@seanjtaylor
seanjtaylor / check.log
Created January 24, 2017 21:17
configure.win only
* using log directory 'd:/RCompile/CRANguest/R-release/prophet.Rcheck'
* using R version 3.3.2 (2016-10-31)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'prophet/DESCRIPTION' ... OK
* this is package 'prophet' version '0.1'
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Sean Taylor <[email protected]>'
New submission