Created
January 4, 2016 19:31
-
-
Save tcash21/6578779cfbf9804d67de to your computer and use it in GitHub Desktop.
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
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" | |
q_body <- list(player_id="nba-stephen-curry") | |
ep <- "game_logs" | |
## Query the API | |
sc_logs <- ss_get_result(sport=sport, league=league, ep=ep, query=q_body, version=1, walk=TRUE) | |
## Add some game details to the data | |
games <- sc_logs[[1]]$games | |
the_games<-sc_logs[[1]]$game_logs[match(games$id, sc_logs[[1]]$game_logs$game_id),] | |
the_games$name <- games$name | |
the_games$date <- as.Date(games$started_at) | |
## Write out .csv file for Tableau | |
write.csv(the_games, file="steph_curry_game_logs.csv", row.names = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment