Last active
August 29, 2015 14:15
-
-
Save durtal/f0ca54e7aacb92130a1e to your computer and use it in GitHub Desktop.
Gulfstream App Data
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) | |
} | |
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