|
1 |
| -#' Load Official Game Stats |
2 |
| -#' |
3 |
| -#' @description Loads weekly stats for all passers, rushers and receivers in the |
4 |
| -#' nflfastR play-by-play data from the 1999 season to the most recent season |
5 |
| -#' |
6 |
| -#' @param qs Whether to use the function [qs::qdeserialize()] for more efficient loading. |
7 |
| -#' @return Weekly stats for all passers, rushers and receivers in the nflfastR |
8 |
| -#' play-by-play data from the 1999 season to the most recent season |
| 1 | +#' @inherit nflreadr::load_player_stats |
| 2 | +#' @inheritDotParams nflreadr::load_player_stats |
| 3 | +#' @param qs `r lifecycle::badge("deprecated")` has no effect and will be |
| 4 | +#' removed in a future release. |
| 5 | +#' @param ... Arguments passed on to nflreadr::load_player_stats |
9 | 6 | #'
|
10 | 7 | #' @seealso The function [calculate_player_stats()] and the corresponding examples
|
11 | 8 | #' on [the nflfastR website](https://www.nflfastr.com/articles/nflfastR.html#example-11-replicating-official-stats)
|
|
15 | 12 | #' dplyr::glimpse(stats)
|
16 | 13 | #' }
|
17 | 14 | #' @export
|
18 |
| -load_player_stats <- function(qs = FALSE) { |
19 |
| - |
20 |
| - if (isTRUE(qs) && !is_installed("qs")) { |
21 |
| - cli::cli_abort("Package {.val qs} required for argument {.val qs = TRUE}. Please install it.") |
| 15 | +load_player_stats <- function(..., qs = lifecycle::deprecated()){ |
| 16 | + if (lifecycle::is_present(qs)) { |
| 17 | + lifecycle::deprecate_warn( |
| 18 | + when = "4.3.0", |
| 19 | + what = "load_pbp(qs = )", |
| 20 | + details = cli::cli_text("The {.val qs} argument is deprecated and replaced by {.val file_type} - see {.code ?nflreadr::load_player_stats} for details.") |
| 21 | + ) |
22 | 22 | }
|
23 | 23 |
|
24 |
| - if (isTRUE(qs)) { |
25 |
| - .url <- "https://github.com/nflverse/nflfastR-data/blob/master/data/player_stats.qs?raw=true" |
26 |
| - out <- qs_from_url(.url) |
27 |
| - } else { |
28 |
| - .url <- "https://github.com/nflverse/nflfastR-data/blob/master/data/player_stats.rds?raw=true" |
29 |
| - con <- url(.url) |
30 |
| - out <- readRDS(con) |
31 |
| - close(con) |
| 24 | + # if the dots are empty, we now have the same behavior like nflreadr which |
| 25 | + # differs from the previous versions where it was "load all seasons" |
| 26 | + if (rlang::is_empty(list(...))){ |
| 27 | + cli::cli_warn( |
| 28 | + c("We have changed the behavior of {.var load_player_stats()} as of nflfastR 4.3.0.", |
| 29 | + "Calling it without an argument will return the current season only instead of all available seasons.", |
| 30 | + "Please try {.var load_player_stats(seasons = TRUE)} to get all seasons." |
| 31 | + ), |
| 32 | + .frequency = "regularly", .frequency_id = "player_stats_warning" |
| 33 | + ) |
32 | 34 | }
|
33 | 35 |
|
34 |
| - return(out) |
| 36 | + # if dots are not empty, use them in nflreadr |
| 37 | + nflreadr::load_player_stats(...) |
35 | 38 | }
|
0 commit comments