Skip to content

Instantly share code, notes, and snippets.

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(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),]
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'
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"
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();