Skip to content

Commit

Permalink
keep epa variables NA if all are NA
Browse files Browse the repository at this point in the history
(instead of making it 0 with na.rm = TRUE)
  • Loading branch information
mrcaseb committed Mar 1, 2021
1 parent 24ec23f commit e648e88
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/aggregate_game_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ calculate_player_stats <- function(pbp, weekly = FALSE) {
passing_air_yards = sum(.data$passing_air_yards),
passing_yards_after_catch = sum(.data$passing_yards_after_catch),
passing_first_downs = sum(.data$passing_first_downs),
passing_epa = sum(.data$passing_epa, na.rm = TRUE),
passing_epa = dplyr::if_else(all(is.na(.data$passing_epa)), NA_real_, sum(.data$passing_epa, na.rm = TRUE)),
passing_2pt_conversions = sum(.data$passing_2pt_conversions),

# rushing
Expand All @@ -456,7 +456,7 @@ calculate_player_stats <- function(pbp, weekly = FALSE) {
rushing_tds = sum(.data$rushing_tds),
rushing_fumbles_lost = sum(.data$rushing_fumbles_lost),
rushing_first_downs = sum(.data$rushing_first_downs),
rushing_epa = sum(.data$rushing_epa, na.rm = TRUE),
rushing_epa = dplyr::if_else(all(is.na(.data$rushing_epa)), NA_real_, sum(.data$rushing_epa, na.rm = TRUE)),
rushing_2pt_conversions = sum(.data$rushing_2pt_conversions),

# receiving
Expand All @@ -468,7 +468,7 @@ calculate_player_stats <- function(pbp, weekly = FALSE) {
receiving_air_yards = sum(.data$receiving_air_yards),
receiving_yards_after_catch = sum(.data$receiving_yards_after_catch),
receiving_first_downs = sum(.data$receiving_first_downs),
receiving_epa = sum(.data$receiving_epa, na.rm = TRUE),
receiving_epa = dplyr::if_else(all(is.na(.data$receiving_epa)), NA_real_, sum(.data$receiving_epa, na.rm = TRUE)),
receiving_2pt_conversions = sum(.data$receiving_2pt_conversions),

# fantasy
Expand Down

0 comments on commit e648e88

Please sign in to comment.