Skip to content

Commit

Permalink
skip empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Nov 13, 2024
1 parent d2f3629 commit 9d68987
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/calculate_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ calculate_stats <- function(seasons = nflreadr::most_recent_season(),
pbp <- nflreadr::load_pbp(seasons = seasons)
if (season_type %in% c("REG", "POST") && summary_level == "season") {
pbp <- dplyr::filter(pbp, .data$season_type == .env$season_type)
if (nrow(pbp) == 0){
cli::cli_alert_warning(
"Filtering {.val {seasons}} data to {.arg season_type} == \\
{.val {season_type}} resulted in 0 rows. Returning empty tibble."
)
return(tibble::tibble())
}
}

# defensive stats require knowledge of which team is on defense
Expand Down

0 comments on commit 9d68987

Please sign in to comment.