Skip to content

Instantly share code, notes, and snippets.

Jonathan Robinson jonrobinson2

Block or report user

Report or block jonrobinson2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View upshot_certainty_gap.R
remove(list=ls())
require(jsonlite)
require(ggplot2)
require(reshape2)
require(scales)
jr=theme(panel.background = element_rect(fill = NA, colour = "black", size = 0.25),
panel.border = element_blank(),
panel.grid.major = element_line(colour = "black", size = 0.05),
panel.grid.minor = element_line(colour = "black", size = 0.05),
View evil_fairvote_scraping.R
require(data.table)
require(sqldf)
require(rvest)
require(dplyr)
fairvote=read_html('https://infogram.com/cong-primaries-by-party-1g0n2owgxvyrp4y') %>%
html_nodes('script') %>%
html_text()
fairvote=fairvote[[7]]
fairvote=unlist(strsplit(x = fairvote,fixed = T, split = c('[\"','\"]')))
View logistic_intercept_shift.R
require(arm)
set.seed(987654321)
.tmp=(rnorm(100000, mean=0))
.tmp=invlogit(.tmp)
shift_param=.3
par(mfrow=c(1,3))
hist(x=.tmp, main=paste0('Mean=',round(mean(.tmp),3)))
View gist:c8f2913d32bf65d91d0fd905bfc22ffa
remove(list=ls())
require(googlesheets)
require(dplyr)
require(stringr)
#options(error = expression(NULL))
list_sheets=gs_ls()
wedding_list=gs_title("Jonarobin Master Wedding List")
@jonrobinson2
jonrobinson2 / cavs.R
Created May 6, 2016
Quick and Dirty not too pretty season stats
View cavs.R
require(httr)
require(jsonlite)
require(ggplot2)
require(gridExtra)
require(directlabels)
cavs_reg=fromJSON('http://stats.nba.com/stats/teamgamelog?LeagueID=00&Season=2015-16&SeasonType=Regular+Season&TeamID=1610612739')
cavs_playoffs=fromJSON('http://stats.nba.com/stats/teamgamelog?LeagueID=00&Season=2015-16&SeasonType=Playoffs&TeamID=1610612739')
cavs=data.frame(cavs_reg$resultSets$rowSet)
View hmco_sheriff.R
require(rvest)
require(lubridate)
require(stringr)
require(ggplot2)
age = function(from, to) {
from_lt = as.POSIXlt(from)
to_lt = as.POSIXlt(to)
age = to_lt$year - from_lt$year
View wiz.R
require(httr)
require(jsonlite)
require(ggplot2)
require(gridExtra)
remove(list=ls())
hm=fromJSON('http://stats.nba.com/stats/teamgamelog?LeagueID=00&Season=2015-16&SeasonType=Regular+Season&TeamID=1610612764')
wiz=data.frame(hm$resultSets$rowSet)
View trump_interviewer_mode_effects.R
require(pollstR)
require(ggplot2)
require(magrittr)
remove(list=ls())
tmp=pollstr_polls(max_pages = 10000, chart = '2016-national-gop-primary', after = "2015-3-1")
tmp$questions=tmp$questions[tmp$questions$topic=='2016-president-gop-primary',]
tmp1=merge(tmp$polls, tmp$questions, by='id')
View sql.export.randomForest.R
# sql.export.rf(): save a randomForest model as SQL
# v0.03
# Copyright (c) 2013-2014 Shane Butler <shane dot butler at gmail dot com>
#
# sql.export.rf is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# sql.export.rf is distributed in the hope that it will be useful, but
View sql.export.gbm.R
# sql.export.gbm(): save a GBM model as SQL
# v0.11
# Copyright (c) 2013-2014 Shane Butler <shane dot butler at gmail dot com>
#
# sql.export.gbm is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# sql.export.gbm is distributed in the hope that it will be useful, but
You can’t perform that action at this time.