Skip to content

Instantly share code, notes, and snippets.

@sangamc
Forked from tcash21/stattleship_curry.R
Created August 22, 2016 20:48
Show Gist options
  • Save sangamc/d82b94446cfc3e2ffc03c8f8e6d7e37d to your computer and use it in GitHub Desktop.
Save sangamc/d82b94446cfc3e2ffc03c8f8e6d7e37d to your computer and use it in GitHub Desktop.
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