This file contains 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
bf <- betfair(usr = Sys.getenv("BETFAIR_USR"), | |
pwd = Sys.getenv("BETFAIR_PWD"), | |
key = Sys.getenv("BETFAIR_KEY")) | |
outlist <- vector("list", 120) | |
for(i in 1:120) { | |
# sleep for 60seconds | |
Sys.sleep(60) | |
# collect marketCatalogue data, contains team names | |
tmp <- bf$marketCatalogue(filter = marketFilter(marketIds = "1.121198987"), |
This file contains 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
gulf_races_helper <- function(race) { | |
runners <- ldply(race$runners, data.frame, stringsAsFactors = FALSE) | |
details <- data.frame(race$details, stringsAsFactors = FALSE) | |
conditions <- data.frame(race$conditions, stringsAsFactors = FALSE) | |
date_race <- data.frame(date = race$date, | |
date_race = race$date_race, | |
race = race$race, | |
stringsAsFactors = FALSE) | |
This file contains 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
gulf_ratings <- function(ratings, .progress = "none") { | |
ratings <- ldply(ratings, .fun = gulf_ratings_helper, .progress = .progress) | |
id <- sapply(1:ncol(ratings), FUN = function(x) is.factor(ratings[, x])) | |
ratings[, id] <- lapply(ratings[, id], as.character) | |
return(ratings) | |
} |
This file contains 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
# SHORT SCRIPT TO GET TURFTRAX TIMES FROM PDF INTO R | |
# example PDF http://www.turftrax.co.uk/tracking/Glorious2014/GWD290714R1_1M2F.pdf | |
# highlight horses names and times in the table in Turftrax PDF using mouse | |
# (don't highlight the table headers) | |
# copy to clipboard using "Ctrl-C" | |
# in R (once PDF table is copied to clipboard) | |
df <- read.delim("clipboard", h=F, stringsAsFactors=F) |
This file contains 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(ggplot2) | |
#Load Data | |
#Make sure months stay ordered - first time I ever wanted a factor! | |
#Label x-axis with every fifth label | |
visits_visitors <- read.csv("visits_visitors.csv") | |
visits_visitors$Month <- factor(visits_visitors$Month, levels = visits_visitors$Month, ordered = TRUE) | |
visits_visitors$Month_ <- ifelse(as.numeric(row.names(visits_visitors)) %% 5 == 0, as.character(visits_visitors$Month), "") | |
#Build plot as a series of elements |