Skip to content

Instantly share code, notes, and snippets.

@durtal
Created May 21, 2015 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save durtal/f4c02bda609bb79b59d0 to your computer and use it in GitHub Desktop.
Save durtal/f4c02bda609bb79b59d0 to your computer and use it in GitHub Desktop.
Helper funs to get data from Gulfstream app (durtal.github.io/gulfstream) into R
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)
compdf <- data.frame(date_race, details, conditions, runners)
return(compdf)
}
gulf_races <- function(races, .progress = "none") {
races <- ldply(races, .fun = gulf_races_helper, .progress = .progress)
id <- sapply(1:ncol(races), FUN = function(x) is.factor(races[,x]))
races[,id] <- lapply(races[,id], as.character)
return(races)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment