-
Notifications
You must be signed in to change notification settings - Fork 100
Home
The update process for the projection_sources.rda
file should be as follows:
- Update
R/source_classes.R
if needed. If not, skip step 3. - Build package
- Run
data-raw/source_configs.R
(this script will updatedata/projection_sources.rda
) - Build package
The standard.rda
file is generated using the use_data function in the usethis package https://usethis.r-lib.org/reference/use_data.html
To update the standard.rda
(or sysdata.rds
?) file, you will have to update the ffanalytics:::player_ids
object and then rewrite it into the package with the use_data function. This is a bit labor intensive but allows for robust mapping of players to a common id. Add MFL IDs of the rookies that were added by MFL in the beginning of the season and then find the respective ids for the sources and add them in. (This can be done in a spreadsheet).
If you look at the results from running scrape_data you will see that some players will have values in the src_id
column but no value in the id
column. This would be the players that would need to be added/updated in the ffanalytics::::player_ids
object.
This player_directories
script will parse player directories for CBS, FFToday, Fantasypros and NFL. Make sure you load the ffanalytics
package first to have access to tidyverse
and rvest
. The command to create the sysdata.rda
file is usethis::use_data(player_ids, overwrite = TRUE, internal = TRUE)
. This command needs to be executed from the package root folder.
If you want to do a quick check to see if there are new players that needs to be added to the ffanalytics:::player_ids
table then you can run player_table %>% filter(!(id %in% ffanalytics:::player_ids$id))
Randal Morris noted, "Below is what I use to get majority of the missing Ids left. Pretty much gets anyone with any relevance."
player_table1 <<- httr::GET("https://api.myfantasyleague.com/2020/export?TYPE=players&L=&APIKEY=&DETAILS=1&SINCE=&PLAYERS=&JSON=1") %>%
httr::content() %>% [[("players") %>% [[("player") %>%
purrr::map(tibble::as_tibble) %>%
dplyr::bind_rows() %>%
tidyr::extract(name, c("last_name", "first_name"), "(.+),\s(.+)") %>%
mutate_all(funs(gsub("(?![.-])[[:punct:]]", "", ., perl = T))) %>%
dplyr::mutate(name = paste0(first_name," ",last_name)) %>%
dplyr::select(id,name)
for (p in list("QB","RB","WR","TE","K")) {
for (j in 1:length(my_scrape[[p]][["id"]])){
if (is.na(my_scrape[[p]][["id"]][[j]])) {
my_scrape[[p]][["id"]][[j]] <- as.character(player_table1[match(my_scrape[[p]][["player"]][[j]], player_table1$name),1])
}
}
}
rm(player_table1)