This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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),] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(stattleshipR) | |
| library(dplyr) | |
| library(ggplot2) | |
| set_token("YOUR_TOKEN_GOES_HERE") | |
| ## pull all 'team_game_logs' from the Stattleship API | |
| ## set parameters here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(radarchart) | |
| labs <- c(1:25) | |
| scores <- list("Rich" = rnorm(25, 1, 10), | |
| "Andy" = rnorm(25, 10, 5), | |
| "Aimee" = rnorm(25, 20, 5)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| conditionalPanel(id='loader', | |
| condition="($('html').hasClass('shiny-busy'))", | |
| img(src="spinner.gif") | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |