/
R_main_baseballCloser.R
33 lines (23 loc) · 1.03 KB
/
R_main_baseballCloser.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
closer_analysis <- function(){
## Enter your information here --------------------------------------------------------
league_ID <- 30362;
league_sport <- 'mlb';
league_year <- 2017;
# Get Yahoo Credentials:
# NOTE: You can just paste yours in here instead of storing them in a file like me.
cKey <- readLines("myPrivateKey.txt")[1];
cSecret <- readLines("myPrivateKey.txt")[2];
## Authenticate Yahoo API credentials -------------------------------------------------
# If our token is already saved, use it. Otherwise, get it again.
yahoo_token <- tryCatch({
load("yahoo_token.Rdata");
yahoo_token;
}, error =function(e){
yahoo_token <- yahooFantasy_get_oauth_token(cKey,cSecret);
return(yahoo_token);
})
## Figure out the correct Game_ID and league Key ---------------------------------------
game_ID <- yahooFantasy_get_gameID(league_sport,league_year,yahoo_token);
leagueKey <- paste0(game_ID,'.l.',league_ID);
allRelievers <- yahooFantasy_get_allRelievers(leagueKey,yahoo_token);
}