Skip to content

Instantly share code, notes, and snippets.

@durtal
Last active August 29, 2015 14:15
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/f0ca54e7aacb92130a1e to your computer and use it in GitHub Desktop.
Save durtal/f0ca54e7aacb92130a1e to your computer and use it in GitHub Desktop.
Gulfstream App Data
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)
}
gulf_ratings_helper <- function(horse) {
id <- horse$'_id'
yob <- horse$yob
current_trainer <- horse$trainer
races <- horse$races
racesdf <- ldply(races, function(race) {
data.frame(date = race$date, race = race$race, date_race = race$date_race,
race$details, race$conditions, race$runners)
})
compdf <- data.frame(id, yob, current_trainer, racesdf, stringsAsFactors = F)
return(compdf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment