Skip to content

Instantly share code, notes, and snippets.

devtools::install_github("stattleship/stattleship-r")
library(stattleshipR)
## Sign up for one of these from www.stattleship.com
set_token('your-API-token')
## Set the parameters according to
## playbook.stattleship.com
league <- "nba"
sport <- "basketball"
devtools::install_github("stattleship/stattleship-r")
library(stattleshipR)
## Get a free Stattleship API token from www.stattleship.com
set_token('set-your-token')
sport <- 'football'
league <- 'nfl'
ep <- 'game_logs'
import praw
import re
import pandas as pd
import tinys3
## S3 Connection Credentials
conn = tinys3.Connection('S3_ACCESS_KEY','S3_SECRET_KEY',tls=True)
## Login to Reddit
r = praw.Reddit(user_agent='Live r/NFL Game Thread Scraper')
@tcash21
tcash21 / server.R
Created January 18, 2016 17:18
Reddit Live Game Thread Swears by Fanbase Dashboard
library(stattleshipR)
library(ggplot2)
library(dplyr)
library(shiny)
library(shinydashboard)
library(RCurl)
## get a free Stattleship API token from www.stattleship.com
set_token("stattleship-token")
library(lpSolve)
preds$team <-as.character(preds$team)
obj = preds$prediction
con <- rbind(t(model.matrix(~ FD.Position + 0,preds)), t(model.matrix(~ team + 0, preds)), rep(1,nrow(preds)), preds$Salary)
dir <- c(">=",">=",">=",">=",">=",rep('<=',length(unique(preds$team))),"<=","<=")
rhs <- c(1,2,2,2,2,rep(4,length(unique(preds$team))),9,60000)
result = lp("max", obj, con, dir, rhs, all.bin = TRUE)
preds[which(result$solution == 1),]
install.packages("devtools")
devtools::install_github("stattleship/stattleship-r")
install.packages('dplyr')
install.packages('ggplot2')
## Load the stattleshipR package
library(stattleshipR)
library(dplyr)
library(ggplot2)
library(stattleshipR)
library(dplyr)
library(ggplot2)
set_token("YOUR_TOKEN_GOES_HERE")
## pull all 'team_game_logs' from the Stattleship API
## set parameters here
@tcash21
tcash21 / server.R
Created September 7, 2016 18:03
radarchart jittery issue
library(radarchart)
labs <- c(1:25)
scores <- list("Rich" = rnorm(25, 1, 10),
"Andy" = rnorm(25, 10, 5),
"Aimee" = rnorm(25, 20, 5))
@tcash21
tcash21 / spinner.gif
Created October 15, 2016 16:26
Shiny loading spinner
conditionalPanel(id='loader',
condition="($('html').hasClass('shiny-busy'))",
img(src="spinner.gif")
),
library(benford.analysis)
## read in data
counties <- read.csv(file="https://raw.githubusercontent.com/Prooffreader/election_2016_data/master/data/presidential_general_election_2016_by_county.csvhttps://raw.githubusercontent.com/Prooffreader/election_2016_data/master/data/presidential_general_election_2016_by_county.csv")
## Run Benford tests
hrc <- benford(subset(counties, name == 'H. Clinton')$votes)
trump <- benford(subset(counties, name == 'D. Trump')$votes)
## plot results