Skip to content

Commit

Permalink
Don't filter week level stats to season_type
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Nov 13, 2024
1 parent 9a517fd commit d2f3629
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion R/calculate_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @param stat_type Calculate `"player"` level stats or `"team"` level stats.
#' @param season_type One of `"REG"`, `"POST"`, or `"REG+POST"`. Filters
#' data to regular season ("REG"), post season ("POST") or keeps all data.
#' Only applied if `summary_level` == `"season"`.
#'
#' @return A tibble of player/team stats summarized by season/week.
#' @seealso [nfl_stats_variables] for a description of all variables.
Expand All @@ -37,7 +38,7 @@ calculate_stats <- function(seasons = nflreadr::most_recent_season(),
season_type <- rlang::arg_match(season_type)

pbp <- nflreadr::load_pbp(seasons = seasons)
if (season_type %in% c("REG", "POST")) {
if (season_type %in% c("REG", "POST") && summary_level == "season") {
pbp <- dplyr::filter(pbp, .data$season_type == .env$season_type)
}

Expand Down
3 changes: 2 additions & 1 deletion man/calculate_stats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d2f3629

Please sign in to comment.