Last active
August 29, 2016 12:58
-
-
Save batpigandme/f57ed4bbd8e345f1601b to your computer and use it in GitHub Desktop.
Gets all game logs for DeAndre Jordan this season from the Stattleship API.
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
## install and load the stattleshipR package | |
devtools::install_github("stattleship/stattleship-r") | |
library(stattleshipR) | |
## get your API token stattleship.com | |
## set your API token | |
set_token('YOUR_ACCESS_TOKEN') | |
## Set params according to | |
## developers.stattleship.com | |
ep <- "game_logs" | |
q_body <- list(season_id="nba-2015-2016", player_id="nba-deandre-jordan") | |
## Query the API | |
deandre_logs <- ss_get_result(sport=sport, league=league, ep=ep, query=q_body, version = 1, walk = TRUE) | |
## Add some game details for context | |
games <- deandre_logs[[1]]$games | |
the_games <- deandre_logs[[1]]$game_logs[match(games$id, deandre_logs[[1]]$game_logs$game_id),] | |
the_games$name <- games$name | |
the_games$scoreline <- games$scoreline | |
the_games$date <- as.Date(games$started_at) | |
the_games$score_differential <- games$score_differential | |
## Write a .csv file for Tableau | |
write.csv(the_games, file="deandre_jordan_logs.csv", row.names = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment