diff --git a/DESCRIPTION b/DESCRIPTION index 40e672bb..4154f5f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: ffscrapr Title: API Client for Fantasy Football League Platforms -Version: 1.4.0 +Version: 1.4.1 Authors@R: c(person(given = "Tan", family = "Ho", @@ -56,6 +56,7 @@ Suggests: rmarkdown (>= 2.6), testthat (>= 2.1.0), withr (>= 2.4.0) +LazyData: true VignetteBuilder: knitr Encoding: UTF-8 diff --git a/NEWS.md b/NEWS.md index f4dbf19e..cc976f64 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,28 @@ +# ffscrapr 1.4.1 + +The main goal of v1.4.1 is to patch some issues raised by CRAN checks and also correct some bugs in the new experimental `ff_scoringhistory` and `ff_starter_positions` functions released in v1.4.0. + +## New features + +- `nflfastr_stat_mapping` is a dataframe that maps nflfastr columns to fantasy scoring rules, and is now exported for end-user usage. It is primarily used inside of `ff_scoringhistory()`. + +## Minor changes + +- Added `release_questions` to help remind me to maintain test infrastructure +- `mfl_starter_positions` now correctly calculates offensive starters (first via "iop_starters" if defined and then otherwise by subtracting idp starters) as well as kdst_starters (Resolves #264) +- Redirected nflfastr download functions to the new nflverse/ repository locations. (Resolves #268) +- `.ffscrapr_env` relocated from being a child of the base environment to being a child of the empty environment (Resolves #269) +- `ff_scoringhistory` refactored and adds better support for MFL's fumbles and firstdowns. (Resolves #265) + +--- + # ffscrapr 1.4.0 The main goal of v1.4.0 is to add preliminary support for connecting ffscrapr to nflfastR weekly data, and to clean up bugs from v1.3.0. Huge thanks goes to [Joe Sydlowski](https://twitter.com/JoeSydlowskiFF) for his contributions on scoring history (and everything else DynastyProcess!) ## New Features -- `nflfastr_weekly()` imports weekly offensive statistics from nflfastR's [data repository](https://github.com/guga31bb/nflfastR-data). -- `nflfastr_rosters()` imports team rosters from nflfastR's [roster repository](https://github.com/mrcaseb/nflfastR-roster). +- `nflfastr_weekly()` imports weekly offensive statistics from nflfastR's [data repository](https://github.com/nflverse/nflfastR-data). +- `nflfastr_rosters()` imports team rosters from nflfastR's [roster repository](https://github.com/nflverse/nflfastR-roster). - `ff_scoringhistory()` connects your league's scoring settings to the nflfastr data (c/o the functions above), and allows you to reconstruct historical scoring for your league! - `ff_starter_positions()` describes the starter rules for each player/position, including min and max starters at each position accounting for flex spots. This should be useful for calculating things like value over replacement! diff --git a/R/0_helpers.R b/R/0_helpers.R index 27980cae..cc4843c6 100644 --- a/R/0_helpers.R +++ b/R/0_helpers.R @@ -150,3 +150,33 @@ set_unescaped_cookies <- function(...) { httr::config(cookie = cookie) } + +#' Release questions +#' +#' @keywords internal +#' +release_bullets <- function(){ + + #nocov start + + c( + "Tag the current version of ffscrapr-tests as a release version", + 'Switch all vignettes and tests to use "ffscrapr-tests-v1.x.x" and download "archive/v1.x.x"' + ) + + #nocov end + +} + +#' Mappings for nflfastr to fantasy platform scoring +#' +#' A small helper dataframe for connecting nflfastr to specific fantasy platform rules. +#' +#' @format A data frame with ~85 rows and 3 variables: +#' \describe{ +#' \item{nflfastr_event}{the column name of the statistic in the nflfastr_weekly dataset} +#' \item{platform}{specific platform that this mapping applies to} +#' \item{ff_event}{name of the statistic for that platform} +#' } +#' +"nflfastr_stat_mapping" diff --git a/R/1_import_nflfastr.R b/R/1_import_nflfastr.R index 3d3cb9e7..c69d8623 100644 --- a/R/1_import_nflfastr.R +++ b/R/1_import_nflfastr.R @@ -26,7 +26,7 @@ nflfastr_weekly <- function(type = c("offense", "defense", "all")) { file_name <- match.arg(type) - url_query <- "https://github.com/guga31bb/nflfastR-data/raw/master/data/player_stats.rds" + url_query <- "https://github.com/nflverse/nflfastR-data/raw/master/data/player_stats.rds" response <- httr::RETRY("GET", url_query) @@ -66,7 +66,7 @@ nflfastr_weekly <- function(type = c("offense", "defense", "all")) { nflfastr_rosters <- function(seasons) { checkmate::assert_numeric(seasons, lower = 1999, upper = lubridate::year(Sys.Date())) - urls <- glue::glue("https://github.com/mrcaseb/nflfastR-roster/raw/master/data/seasons/roster_{seasons}.rds") + urls <- glue::glue("https://github.com/nflverse/nflfastR-roster/raw/master/data/seasons/roster_{seasons}.rds") df_rosters <- purrr::map_df(urls, .nflfastr_roster) diff --git a/R/espn_scoringhistory.R b/R/espn_scoringhistory.R index 9680554e..bd836bf8 100644 --- a/R/espn_scoringhistory.R +++ b/R/espn_scoringhistory.R @@ -20,7 +20,10 @@ ff_scoringhistory.espn_conn <- function(conn, season = 1999:2020, ...) { # Pull in scoring rules for that league league_rules <- - ff_scoring(conn) + ff_scoring(conn) %>% + dplyr::left_join( + nflfastr_stat_mapping %>% dplyr::filter(.data$platform == "espn"), + by = c("stat_name" = "ff_event")) # Use custom ffscrapr function to get positions fron nflfastR rosters fastr_rosters <- @@ -41,8 +44,7 @@ ff_scoringhistory.espn_conn <- function(conn, season = 1999:2020, ...) { "special_teams_tds" ) ) %>% - dplyr::inner_join(stat_mapping, by = c("metric" = "nflfastr_event")) %>% - dplyr::inner_join(league_rules, by = c("espn_event" = "stat_name", "position" = "pos")) %>% + dplyr::inner_join(league_rules, by = c("metric" = "nflfastr_event", "position" = "pos")) %>% dplyr::mutate(points = .data$value * .data$points) %>% dplyr::group_by(.data$season, .data$week, .data$player_id, .data$sportradar_id) %>% dplyr::mutate(points = round(sum(.data$points, na.rm = TRUE), 2)) %>% diff --git a/R/flea_scoringhistory.R b/R/flea_scoringhistory.R index b5202419..16860672 100644 --- a/R/flea_scoringhistory.R +++ b/R/flea_scoringhistory.R @@ -8,10 +8,8 @@ #' #' @examples #' \donttest{ -#' #' -#' conn <- fleaflicker_connect(2020, 312861) -#' x <- ff_scoringhistory(conn, season = 2020) -#' x +#' # conn <- fleaflicker_connect(2020, 312861) +#' ff_scoringhistory(conn, season = 2020) #' } #' #' @describeIn ff_scoringhistory Fleaflicker: returns scoring history in a flat table, one row per player per week. @@ -22,7 +20,12 @@ ff_scoringhistory.flea_conn <- function(conn, season = 1999:2020, ...) { # Pull in scoring rules for that league league_rules <- - ff_scoring(conn) + ff_scoring(conn) %>% + dplyr::left_join( + nflfastr_stat_mapping %>% + dplyr::filter(.data$platform == "fleaflicker") %>% + dplyr::mutate(ff_event = as.integer(.data$ff_event)), + by = c("event_id" = "ff_event")) # Use custom ffscrapr function to get positions fron nflfastR rosters fastr_rosters <- @@ -43,8 +46,7 @@ ff_scoringhistory.flea_conn <- function(conn, season = 1999:2020, ...) { "special_teams_tds" ) ) %>% - dplyr::inner_join(stat_mapping, by = c("metric" = "nflfastr_event")) %>% - dplyr::inner_join(league_rules, by = c("fleaflicker_event" = "event_id", "position" = "pos")) %>% + dplyr::inner_join(league_rules, by = c("metric" = "nflfastr_event", "position" = "pos")) %>% dplyr::mutate(points = .data$value * .data$points) %>% dplyr::group_by(.data$season, .data$week, .data$player_id, .data$sportradar_id) %>% dplyr::mutate(points = round(sum(.data$points, na.rm = TRUE), 2)) %>% diff --git a/R/mfl_scoringhistory.R b/R/mfl_scoringhistory.R index 5ecf26d1..1e900845 100644 --- a/R/mfl_scoringhistory.R +++ b/R/mfl_scoringhistory.R @@ -29,16 +29,31 @@ ff_scoringhistory.mfl_conn <- function(conn, season = 1999:2020, ...) { dplyr::mutate(dplyr::across( .cols = c("lower_range", "upper_range"), .fns = as.numeric - )) + )) %>% + dplyr::left_join( + nflfastr_stat_mapping %>% dplyr::filter(.data$platform == "mfl"), + by = c("event" = "ff_event")) %>% + dplyr::select( + "pos","points","lower_range","upper_range","event", "nflfastr_event", "short_desc" + ) - # Use custom ffscrapr function to get positions fron nflfastR rosters + # Use custom ffscrapr function to get positions from nflfastR rosters fastr_rosters <- nflfastr_rosters(season) %>% dplyr::mutate(position = dplyr::if_else(.data$position %in% c("HB", "FB"), "RB", .data$position)) # Load stats from nflfastr and map the rules from the internal stat_mapping file - nflfastr_weekly() %>% + fastr_weekly <- nflfastr_weekly() %>% dplyr::inner_join(fastr_rosters, by = c("player_id" = "gsis_id", "season" = "season")) %>% + dplyr::select( + "season", "player_id", "sportradar_id", "position", "full_name","recent_team","week", + "completions", "attempts", "passing_yards", "passing_tds", "interceptions", "sacks", + "sack_fumbles_lost", "passing_first_downs", "passing_2pt_conversions", "carries", + "rushing_yards", "rushing_tds", "rushing_fumbles_lost", "rushing_first_downs", + "rushing_2pt_conversions", "receptions", "targets", "receiving_yards", "receiving_tds", + "receiving_fumbles_lost", "receiving_first_downs", "receiving_2pt_conversions", + "special_teams_tds", "sack_yards", "rushing_fumbles", "receiving_fumbles", "sack_fumbles" + ) %>% tidyr::pivot_longer( names_to = "metric", cols = c( @@ -47,18 +62,17 @@ ff_scoringhistory.mfl_conn <- function(conn, season = 1999:2020, ...) { "rushing_yards", "rushing_tds", "rushing_fumbles_lost", "rushing_first_downs", "rushing_2pt_conversions", "receptions", "targets", "receiving_yards", "receiving_tds", "receiving_fumbles_lost", "receiving_first_downs", "receiving_2pt_conversions", - "special_teams_tds" + "special_teams_tds", "sack_yards", "rushing_fumbles", "receiving_fumbles", "sack_fumbles" ) ) %>% - dplyr::inner_join(stat_mapping, by = c("metric" = "nflfastr_event")) %>% - dplyr::inner_join(league_rules, by = c("mfl_event" = "event", "position" = "pos")) %>% + dplyr::inner_join(league_rules, by = c("metric" = "nflfastr_event", "position" = "pos")) %>% dplyr::filter(.data$value >= .data$lower_range, .data$value <= .data$upper_range) %>% dplyr::mutate(points = .data$value * .data$points) %>% dplyr::group_by(.data$season, .data$week, .data$player_id, .data$sportradar_id) %>% dplyr::mutate(points = round(sum(.data$points, na.rm = TRUE), 2)) %>% dplyr::ungroup() %>% dplyr::select("season", "week", - "gsis_id" = "player_id", "sportradar_id", "player_name", "pos" = "position", + "gsis_id" = "player_id", "sportradar_id", "player_name"="full_name", "pos" = "position", "team" = "recent_team", "metric", "value", "points" ) %>% tidyr::pivot_wider( @@ -68,4 +82,6 @@ ff_scoringhistory.mfl_conn <- function(conn, season = 1999:2020, ...) { values_fill = 0, values_fn = max ) + + return(fastr_weekly) } diff --git a/R/mfl_starterpositions.R b/R/mfl_starterpositions.R index 59a7f4b4..ba1d0799 100644 --- a/R/mfl_starterpositions.R +++ b/R/mfl_starterpositions.R @@ -9,18 +9,24 @@ #' #' @examples #' \donttest{ -#' dlfidp_conn <- mfl_connect(2020, league_id = 54040) +#' dlfidp_conn <- mfl_connect(2020, league_id = 33158) #' ff_starter_positions(conn = dlfidp_conn) #' } #' #' @export ff_starter_positions.mfl_conn <- function(conn, ...) { + starter_positions <- mfl_getendpoint(conn, "league") %>% purrr::pluck("content", "league", "starters") %>% list() %>% tibble::tibble() %>% - tidyr::hoist(1, "total_starters" = "count", "defense_starters" = "idp_starters", "position") %>% + tidyr::hoist( + 1, + "total_starters" = "count", + "defense_starters" = "idp_starters", + "offense_starters" = "iop_starters", + "position") %>% tidyr::unnest_longer("position") %>% tidyr::hoist("position", "pos" = "name", "limit") %>% tidyr::separate("limit", into = c("min", "max"), sep = "\\-", fill = "right") %>% @@ -28,7 +34,10 @@ ff_starter_positions.mfl_conn <- function(conn, ...) { dplyr::mutate( max = dplyr::coalesce(.data$max, .data$min), defense_starters = dplyr::coalesce(as.integer(.data[["defense_starters"]]), 0), - offense_starters = as.integer(.data$total_starters) - .data$defense_starters + kdst_starters = sum(.data$pos %in% c("DEF","PK","PN","TMPK","TMPN","Coach","ST") * .data$min), + offense_starters = dplyr::coalesce( + as.integer(.data[["offense_starters"]]), + as.integer(.data$total_starters) - .data$defense_starters - .data$kdst_starters) ) %>% dplyr::select( "pos", @@ -36,6 +45,7 @@ ff_starter_positions.mfl_conn <- function(conn, ...) { "max", "offense_starters", "defense_starters", + "kdst_starters", "total_starters" ) diff --git a/R/sleeper_draftpicks.R b/R/sleeper_draftpicks.R index 49503d7a..10a41e20 100644 --- a/R/sleeper_draftpicks.R +++ b/R/sleeper_draftpicks.R @@ -63,8 +63,9 @@ ff_draftpicks.sleeper_conn <- function(conn, ...) { purrr::pluck("content") draft_rounds <- league_settings %>% - purrr::pluck("settings", "draft_rounds") %>% - seq_len() + purrr::pluck("settings", "draft_rounds") + + draft_rounds <- seq_len(draft_rounds) # Seems to be that you can only trade three years in advance, hard-coded into the platform seasons <- league_settings %>% diff --git a/R/sleeper_scoringhistory.R b/R/sleeper_scoringhistory.R index 73f9a496..3b47c0b9 100644 --- a/R/sleeper_scoringhistory.R +++ b/R/sleeper_scoringhistory.R @@ -9,8 +9,8 @@ #' @examples #' \donttest{ #' #' -#' conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) -#' ff_scoringhistory(conn, season = 2020) +#' # conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) +#' # ff_scoringhistory(conn, season = 2020) #' } #' #' @describeIn ff_scoringhistory Sleeper: returns scoring history in a flat table, one row per player per week. @@ -21,7 +21,10 @@ ff_scoringhistory.sleeper_conn <- function(conn, season = 1999:2020, ...) { # Pull in scoring rules for that league league_rules <- - ff_scoring(conn) + ff_scoring(conn) %>% + dplyr::left_join( + nflfastr_stat_mapping %>% dplyr::filter(.data$platform == "sleeper"), + by = c("event" = "ff_event")) # Use custom ffscrapr function to get positions fron nflfastR rosters fastr_rosters <- @@ -42,8 +45,7 @@ ff_scoringhistory.sleeper_conn <- function(conn, season = 1999:2020, ...) { "special_teams_tds" ) ) %>% - dplyr::inner_join(stat_mapping, by = c("metric" = "nflfastr_event")) %>% - dplyr::inner_join(league_rules, by = c("sleeper_event" = "event", "position" = "pos")) %>% + dplyr::inner_join(league_rules, by = c("metric" = "nflfastr_event", "position" = "pos")) %>% dplyr::mutate(points = .data$value * .data$points) %>% dplyr::group_by(.data$season, .data$week, .data$player_id, .data$sportradar_id) %>% dplyr::mutate(points = round(sum(.data$points, na.rm = TRUE), 2)) %>% diff --git a/R/sysdata.rda b/R/sysdata.rda index 9c8969ed..a0d202fb 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/zzz.R b/R/zzz.R index 6ce328da..5b8c8eb5 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,5 +1,7 @@ #### On Load #### +.ffscrapr_env <- new.env(parent = emptyenv()) + .onLoad <- function(libname, pkgname) { # nocov start @@ -89,21 +91,25 @@ # if (memoise_option == "off") packageStartupMessage('Note: ffscrapr.cache is set to "off"') - env <- rlang::env( - user_agent = glue::glue( - "ffscrapr/{utils::packageVersion('ffscrapr')} API client package", - " https://github.com/dynastyprocess/ffscrapr" - ) %>% - httr::user_agent(), - get = ratelimitr::limit_rate(.retry_get, ratelimitr::rate(60, 60)), - get.mfl = ratelimitr::limit_rate(.retry_get, ratelimitr::rate(2, 3)), - get.sleeper = ratelimitr::limit_rate(.retry_get, ratelimitr::rate(30, 2)), - get.flea = ratelimitr::limit_rate(.retry_get, ratelimitr::rate(30, 2)), - get.espn = ratelimitr::limit_rate(.retry_get, ratelimitr::rate(30, 2)), - post = ratelimitr::limit_rate(.retry_post, ratelimitr::rate(60, 60)) - ) - - assign(".ffscrapr_env", env, envir = baseenv()) + user_agent <- glue::glue("ffscrapr/{utils::packageVersion('ffscrapr')} ", + "API client package ", + "https://github.com/dynastyprocess/ffscrapr") %>% + httr::user_agent() + + # get <- ratelimitr::limit_rate(.retry_get, ratelimitr::rate(60, 60)) + get.mfl <- ratelimitr::limit_rate(.retry_get, ratelimitr::rate(2, 3)) + get.sleeper <- ratelimitr::limit_rate(.retry_get, ratelimitr::rate(30, 2)) + get.flea <- ratelimitr::limit_rate(.retry_get, ratelimitr::rate(30, 2)) + get.espn <- ratelimitr::limit_rate(.retry_get, ratelimitr::rate(30, 2)) + post <- ratelimitr::limit_rate(.retry_post, ratelimitr::rate(60, 60)) + + + assign("user_agent",user_agent, envir = .ffscrapr_env) + assign("get.mfl",get.mfl, envir = .ffscrapr_env) + assign("get.sleeper",get.sleeper, envir = .ffscrapr_env) + assign("get.flea",get.flea, envir = .ffscrapr_env) + assign("get.espn",get.espn, envir = .ffscrapr_env) + assign("post",post, envir = .ffscrapr_env) # nocov end } diff --git a/README.Rmd b/README.Rmd index fd3308c2..eb402ba6 100644 --- a/README.Rmd +++ b/README.Rmd @@ -23,17 +23,17 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) httptest::use_mock_api() ``` -# ffscrapr +# ffscrapr *An R Client for Fantasy Football League APIs* @@ -47,13 +47,13 @@ Helps access various Fantasy Football APIs (currently MFL, Sleeper, Fleaflicker, ### Installation -Version 1.4.0 is now on CRAN :tada: and can be installed with: +Version 1.4.1 is now on CRAN :tada: and can be installed with: ```{r eval = FALSE} install.packages("ffscrapr") # or from GitHub release with the remotes package via: # install.packages("remotes") -remotes::install_github("dynastyprocess/ffscrapr", ref = "v1.4.0") +remotes::install_github("dynastyprocess/ffscrapr", ref = "v1.4.1") ``` Install the development version from GitHub with: @@ -109,5 +109,5 @@ The APIs and data accessed by this package belong to their respective owners, an ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/README.md b/README.md index 43b84d80..c155bde4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# ffscrapr +# ffscrapr *An R Client for Fantasy Football League APIs* @@ -30,13 +30,13 @@ other data sources. ### Installation -Version 1.4.0 is now on CRAN :tada: and can be installed with: +Version 1.4.1 is now on CRAN :tada: and can be installed with: ``` r install.packages("ffscrapr") # or from GitHub release with the remotes package via: # install.packages("remotes") -remotes::install_github("dynastyprocess/ffscrapr", ref = "v1.4.0") +remotes::install_github("dynastyprocess/ffscrapr", ref = "v1.4.1") ``` Install the development version from GitHub with: diff --git a/cran-comments.md b/cran-comments.md index 1b30399c..65b9df38 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,17 +1,19 @@ -## SUBMISSION +## RESUBMISSION + +Corrected url issue in man/nflfastr_stat_mapping.Rd ## CRAN Check Corrections -This release corrects a CRAN check issue where a dependency changed from using digest to cachem as an underlying package. ffscrapr has been rewritten to use cachem as per memoise's suggestions on best practice. +This release corrects a CRAN check issue where a new binding was created in the base environment - this environment binding is now being created inside the empty environment. ## New features -This release adds functions to connect to another source of data. +This release also patches some bugs. ## Test environments -* local (Windows) R installation, R 4.0.4 -* ubuntu 20.04 (on GitHub Actions), R 4.0.4 -* MacOS (on GitHub Actions), R 4.0.4 +* local (Windows) R installation, R 4.0.5 +* ubuntu 20.04 (on GitHub Actions), R 4.0.5 +* MacOS (on GitHub Actions), R 4.0.5 * win-builder (devel) ## R CMD check results diff --git a/data-raw/stat_mapping.csv b/data-raw/stat_mapping.csv index 0aaf8fe3..c5f1abd4 100644 --- a/data-raw/stat_mapping.csv +++ b/data-raw/stat_mapping.csv @@ -1,24 +1,86 @@ -nflfastr_event,mfl_event,fleaflicker_event,sleeper_event,espn_event -completions,PC,,pass_cmp, -attempts,PA,,pass_att, -passing_yards,PY,3,pass_yd,passingYards -passing_tds,#P,5,pass_td,passingTouchdowns -interceptions,IN,7,pass_int,passingInterceptions -sacks,TSK,,pass_sack, -sack_fumbles_lost,FL,27,fum_lost,lostFumbles -passing_first_downs,1P,133,pass_fd, -passing_2pt_conversions,P2,4,pass_2pt,passing2PtConversions -carries,RA,,rush_att, -rushing_yards,RY,22,rush_yd,rushingYards -rushing_tds,#R,24,rush_td,rushingTouchdowns -rushing_fumbles_lost,FL,27,fum_lost,lostFumbles -rushing_first_downs,1R,132,rush_fd, -rushing_2pt_conversions,R2,23,rush_2pt,rushing2PtConversions -receptions,CC,41,rec,receivingReceptions -targets,TGT,,, -receiving_yards,CY,42,rec_yd,receivingYards -receiving_tds,#C,44,rec_td,receivingTouchdowns -receiving_fumbles_lost,FL,27,fum_lost,lostFumbles -receiving_first_downs,1C,131,rec_fd, -receiving_2pt_conversions,C2,43,rec_2pt,receiving2PtConversions -special_teams_tds,#KT,63,def_st_td,kickoffReturnTouchdown +nflfastr_event,platform,ff_event +interceptions,espn,passingInterceptions +passing_2pt_conversions,espn,passing2PtConversions +passing_tds,espn,passingTouchdowns +passing_yards,espn,passingYards +receiving_2pt_conversions,espn,receiving2PtConversions +receiving_fumbles_lost,espn,lostFumbles +receiving_tds,espn,receivingTouchdowns +receiving_yards,espn,receivingYards +receptions,espn,receivingReceptions +rushing_2pt_conversions,espn,rushing2PtConversions +rushing_fumbles_lost,espn,lostFumbles +rushing_tds,espn,rushingTouchdowns +rushing_yards,espn,rushingYards +sack_fumbles_lost,espn,lostFumbles +special_teams_tds,espn,kickoffReturnTouchdown +interceptions,fleaflicker,7 +passing_2pt_conversions,fleaflicker,4 +passing_first_downs,fleaflicker,133 +passing_tds,fleaflicker,5 +passing_yards,fleaflicker,3 +receiving_2pt_conversions,fleaflicker,43 +receiving_first_downs,fleaflicker,131 +receiving_fumbles_lost,fleaflicker,27 +receiving_tds,fleaflicker,44 +receiving_yards,fleaflicker,42 +receptions,fleaflicker,41 +rushing_2pt_conversions,fleaflicker,23 +rushing_first_downs,fleaflicker,132 +rushing_fumbles_lost,fleaflicker,27 +rushing_tds,fleaflicker,24 +rushing_yards,fleaflicker,22 +sack_fumbles_lost,fleaflicker,27 +special_teams_tds,fleaflicker,63 +attempts,mfl,PA +carries,mfl,RA +completions,mfl,PC +interceptions,mfl,IN +passing_2pt_conversions,mfl,P2 +passing_first_downs,mfl,1P +passing_first_downs,mfl,FD +passing_tds,mfl,#P +passing_yards,mfl,PY +receiving_2pt_conversions,mfl,C2 +receiving_first_downs,mfl,1C +receiving_first_downs,mfl,FD +receiving_fumbles,mfl,FUO +receiving_fumbles_lost,mfl,FL +receiving_tds,mfl,#C +receiving_yards,mfl,CY +receptions,mfl,CC +rushing_2pt_conversions,mfl,R2 +rushing_first_downs,mfl,1R +rushing_first_downs,mfl,FD +rushing_fumbles,mfl,FUO +rushing_fumbles_lost,mfl,FL +rushing_tds,mfl,#R +rushing_yards,mfl,RY +sack_fumbles,mfl,FUO +sack_fumbles_lost,mfl,FL +sacks,mfl,TSK +special_teams_tds,mfl,#KT +targets,mfl,TGT +sack_yards,mfl,TSY +attempts,sleeper,pass_att +carries,sleeper,rush_att +completions,sleeper,pass_cmp +interceptions,sleeper,pass_int +passing_2pt_conversions,sleeper,pass_2pt +passing_first_downs,sleeper,pass_fd +passing_tds,sleeper,pass_td +passing_yards,sleeper,pass_yd +receiving_2pt_conversions,sleeper,rec_2pt +receiving_first_downs,sleeper,rec_fd +receiving_fumbles_lost,sleeper,fum_lost +receiving_tds,sleeper,rec_td +receiving_yards,sleeper,rec_yd +receptions,sleeper,rec +rushing_2pt_conversions,sleeper,rush_2pt +rushing_first_downs,sleeper,rush_fd +rushing_fumbles_lost,sleeper,fum_lost +rushing_tds,sleeper,rush_td +rushing_yards,sleeper,rush_yd +sack_fumbles_lost,sleeper,fum_lost +sacks,sleeper,pass_sack +special_teams_tds,sleeper,def_st_td diff --git a/data-raw/usedata_statmapping.R b/data-raw/usedata_statmapping.R index 4ffe5ba2..3f5761f2 100644 --- a/data-raw/usedata_statmapping.R +++ b/data-raw/usedata_statmapping.R @@ -1,5 +1,5 @@ # Import Stat Mapping CSV -stat_mapping <- read.csv("data-raw/stat_mapping.csv") +nflfastr_stat_mapping <- read.csv("data-raw/stat_mapping.csv") # Create Sleeper Rule to Position Mapping conn <- ff_connect(platform = "sleeper", league_id = "653543448376320000", season = 2020) @@ -35,4 +35,6 @@ sleeper_rule_mapping <- tidyr::unnest_longer(col = "pos") %>% dplyr::select(-"points") -usethis::use_data(sleeper_rule_mapping, stat_mapping, overwrite = TRUE, internal = TRUE) +usethis::use_data(nflfastr_stat_mapping, overwrite = TRUE) + +usethis::use_data(sleeper_rule_mapping, overwrite = TRUE, internal = TRUE) diff --git a/data/nflfastr_stat_mapping.rda b/data/nflfastr_stat_mapping.rda new file mode 100644 index 00000000..6cf8ada4 Binary files /dev/null and b/data/nflfastr_stat_mapping.rda differ diff --git a/man/ff_scoringhistory.Rd b/man/ff_scoringhistory.Rd index f61d7a27..a7f31bc7 100644 --- a/man/ff_scoringhistory.Rd +++ b/man/ff_scoringhistory.Rd @@ -51,10 +51,8 @@ ff_scoringhistory(conn) } \donttest{ -#' -conn <- fleaflicker_connect(2020, 312861) -x <- ff_scoringhistory(conn, season = 2020) -x +# conn <- fleaflicker_connect(2020, 312861) +ff_scoringhistory(conn, season = 2020) } \donttest{ @@ -64,8 +62,8 @@ x \donttest{ #' -conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) -ff_scoringhistory(conn, season = 2020) +# conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020) +# ff_scoringhistory(conn, season = 2020) } } diff --git a/man/ff_starter_positions.Rd b/man/ff_starter_positions.Rd index 956ccba8..f117e777 100644 --- a/man/ff_starter_positions.Rd +++ b/man/ff_starter_positions.Rd @@ -54,7 +54,7 @@ ff_starter_positions(conn) } \donttest{ -dlfidp_conn <- mfl_connect(2020, league_id = 54040) +dlfidp_conn <- mfl_connect(2020, league_id = 33158) ff_starter_positions(conn = dlfidp_conn) } diff --git a/man/nflfastr_stat_mapping.Rd b/man/nflfastr_stat_mapping.Rd new file mode 100644 index 00000000..65343143 --- /dev/null +++ b/man/nflfastr_stat_mapping.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/0_helpers.R +\docType{data} +\name{nflfastr_stat_mapping} +\alias{nflfastr_stat_mapping} +\title{Mappings for nflfastr to fantasy platform scoring} +\format{ +A data frame with ~85 rows and 3 variables: +\describe{ + \item{nflfastr_event}{the column name of the statistic in the nflfastr_weekly dataset} + \item{platform}{specific platform that this mapping applies to} + \item{ff_event}{name of the statistic for that platform} +} +} +\usage{ +nflfastr_stat_mapping +} +\description{ +A small helper dataframe for connecting nflfastr to specific fantasy platform rules. +} +\keyword{datasets} diff --git a/man/release_bullets.Rd b/man/release_bullets.Rd new file mode 100644 index 00000000..0f060659 --- /dev/null +++ b/man/release_bullets.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/0_helpers.R +\name{release_bullets} +\alias{release_bullets} +\title{Release questions} +\usage{ +release_bullets() +} +\description{ +Release questions +} +\keyword{internal} diff --git a/pkgdown/extra.css b/pkgdown/extra.css index c1ee8a3b..64a2ddc2 100644 --- a/pkgdown/extra.css +++ b/pkgdown/extra.css @@ -7,17 +7,19 @@ body{ h1 { font-family: 'Fira Mono', sans-serif; + font-weight: 700; } -h1,h2,h3 { +h2,h3 { + font-family: 'IBM Plex Sans', sans-serif; font-weight: 700; } pre, code { - font-family: 'Fira Mono'; + font-family: 'Fira Mono', monospace; } .navbar-link { font-weight: 700; - font-family: 'Fira Mono'; + font-family: 'Fira Mono', sans-serif; } diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 6fba366c..6ca2cea4 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -15,13 +15,13 @@ skip <- FALSE if (download_mock) { tryCatch( expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip", "f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip", "f.zip") unzip("f.zip", exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0") + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1") withr::defer( - unlink(c("ffscrapr-tests-1.4.0", "f.zip"), recursive = TRUE, force = TRUE), + unlink(c("ffscrapr-tests-1.4.1", "f.zip"), recursive = TRUE, force = TRUE), testthat::teardown_env() ) }, diff --git a/tests/testthat/test-ff_scoringhistory.R b/tests/testthat/test-ff_scoringhistory.R index 40df0296..51e45b1a 100644 --- a/tests/testthat/test-ff_scoringhistory.R +++ b/tests/testthat/test-ff_scoringhistory.R @@ -4,9 +4,9 @@ with_mock_api({ if (!identical(Sys.getenv("MOCK_BYPASS"), "true")) { testthat::local_mock( - nflfastr_weekly = function() readRDS("ffscrapr-tests-1.4.0/gh_nflfastr/player_stats.rds"), + nflfastr_weekly = function() readRDS("ffscrapr-tests-1.4.1/gh_nflfastr/player_stats.rds"), nflfastr_rosters = function(seasons) { - purrr::map_df(seasons, ~ readRDS(glue::glue("ffscrapr-tests-1.4.0/gh_nflfastr/roster_{.x}.rds"))) + purrr::map_df(seasons, ~ readRDS(glue::glue("ffscrapr-tests-1.4.1/gh_nflfastr/roster_{.x}.rds"))) } ) } diff --git a/vignettes/espn_basics.Rmd b/vignettes/espn_basics.Rmd index ba2a1cae..22718e4d 100644 --- a/vignettes/espn_basics.Rmd +++ b/vignettes/espn_basics.Rmd @@ -20,10 +20,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -158,6 +158,6 @@ In this vignette, I've used only a few functions: ff_connect, ff_league, ff_rost ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/vignettes/espn_getendpoint.Rmd b/vignettes/espn_getendpoint.Rmd index 1d759bd2..a3ae24c1 100644 --- a/vignettes/espn_getendpoint.Rmd +++ b/vignettes/espn_getendpoint.Rmd @@ -20,10 +20,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -153,5 +153,5 @@ Many of the API endpoints are being researched in other languages and you might ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/vignettes/ffscrapr_scoringhistory.Rmd b/vignettes/ffscrapr_scoringhistory.Rmd index a51912f6..9326281f 100644 --- a/vignettes/ffscrapr_scoringhistory.Rmd +++ b/vignettes/ffscrapr_scoringhistory.Rmd @@ -20,10 +20,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) diff --git a/vignettes/fleaflicker_basics.Rmd b/vignettes/fleaflicker_basics.Rmd index f7c1bdbf..11a1b98c 100644 --- a/vignettes/fleaflicker_basics.Rmd +++ b/vignettes/fleaflicker_basics.Rmd @@ -21,10 +21,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -160,6 +160,6 @@ In this vignette, I've used only a few functions: ff_connect, ff_league, ff_rost ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/vignettes/fleaflicker_getendpoint.Rmd b/vignettes/fleaflicker_getendpoint.Rmd index b896d6e3..edf69e94 100644 --- a/vignettes/fleaflicker_getendpoint.Rmd +++ b/vignettes/fleaflicker_getendpoint.Rmd @@ -20,10 +20,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -121,6 +121,6 @@ From here, you can keep unravelling - including the "viewingActualPoints" and "v ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/vignettes/mfl_basics.Rmd b/vignettes/mfl_basics.Rmd index 84a2f48d..d95e3b88 100644 --- a/vignettes/mfl_basics.Rmd +++ b/vignettes/mfl_basics.Rmd @@ -20,10 +20,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -155,6 +155,6 @@ Now that you've gotten this far, why not check out some of the other possibiliti ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/vignettes/mfl_getendpoint.Rmd b/vignettes/mfl_getendpoint.Rmd index 4a3af73a..31137a00 100644 --- a/vignettes/mfl_getendpoint.Rmd +++ b/vignettes/mfl_getendpoint.Rmd @@ -20,10 +20,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -103,5 +103,5 @@ head(fog_tradebait) ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/vignettes/sleeper_basics.Rmd b/vignettes/sleeper_basics.Rmd index b76bd70b..4acea36e 100644 --- a/vignettes/sleeper_basics.Rmd +++ b/vignettes/sleeper_basics.Rmd @@ -21,10 +21,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -165,6 +165,6 @@ In this vignette, I've used ~three functions: ff_connect, ff_league, and ff_rost ```{r include = FALSE} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ``` diff --git a/vignettes/sleeper_getendpoint.Rmd b/vignettes/sleeper_getendpoint.Rmd index 5d3b3697..9fd04b2f 100644 --- a/vignettes/sleeper_getendpoint.Rmd +++ b/vignettes/sleeper_getendpoint.Rmd @@ -20,10 +20,10 @@ eval <- TRUE tryCatch(expr = { - download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.0.zip","f.zip") + download.file("https://github.com/dynastyprocess/ffscrapr-tests/archive/1.4.1.zip","f.zip") unzip('f.zip', exdir = ".") - httptest::.mockPaths(new = "ffscrapr-tests-1.4.0")}, + httptest::.mockPaths(new = "ffscrapr-tests-1.4.1")}, warning = function(e) eval <<- FALSE, error = function(e) eval <<- FALSE) @@ -93,6 +93,6 @@ There - this means something to us now! As of this writing (2020-11-10), Kalen B ```{r include = FALSE, eval = eval} httptest::stop_mocking() -unlink(c("ffscrapr-tests-1.4.0","f.zip"), recursive = TRUE, force = TRUE) +unlink(c("ffscrapr-tests-1.4.1","f.zip"), recursive = TRUE, force = TRUE) ```