Skip to content

Commit

Permalink
be consistent with counter types
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Jul 19, 2023
1 parent 264cc2f commit b0f554f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/aggregate_game_stats_def.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ calculate_player_stats_def <- function(pbp, weekly = FALSE) {
names_from = .data$desc,
values_from = c(.data$n, .data$sack_yards),
values_fn = sum,
values_fill = 0
values_fill = 0L
) %>%
add_column_if_missing("n_sack", "n_qb_hit", "sack_yards_sack") %>%
dplyr::select(
Expand Down Expand Up @@ -248,7 +248,7 @@ calculate_player_stats_def <- function(pbp, weekly = FALSE) {
names_from = "desc",
values_from = c("n","return_yards"),
values_fn = sum,
values_fill = 0
values_fill = 0L
) %>%
add_column_if_missing(
"n_interception", "n_pass_defense", "return_yards_interception"
Expand Down Expand Up @@ -313,7 +313,7 @@ calculate_player_stats_def <- function(pbp, weekly = FALSE) {
names_from = .data$desc,
values_from = .data$n,
values_fn = sum,
values_fill = 0
values_fill = 0L
) %>%
# Renaming fails if the columns don't exist. So we row bind a dummy tibble
# including the relevant columns. The row will be filtered after renaming
Expand Down Expand Up @@ -367,7 +367,7 @@ calculate_player_stats_def <- function(pbp, weekly = FALSE) {
names_from = .data$desc,
values_from = .data$n,
values_fn = sum,
values_fill = 0
values_fill = 0L
) %>%
dplyr::filter(!is.na(.data$player_id)) %>%
add_column_if_missing("fumble_recovery") %>%
Expand Down Expand Up @@ -456,7 +456,7 @@ calculate_player_stats_def <- function(pbp, weekly = FALSE) {
names_from = .data$desc,
values_from = c(.data$n, .data$yards),
values_fn = sum,
values_fill = 0
values_fill = 0L
) %>%
add_column_if_missing("n_penalty", "yards_penalty") %>%
dplyr::select(
Expand Down Expand Up @@ -603,7 +603,7 @@ calculate_player_stats_def <- function(pbp, weekly = FALSE) {
# This function checks if the variables in ... exists as column
# names in the argument .data. If not, it adds those columns and assigns
# them the value in the argument value
add_column_if_missing <- function(.data, ..., value = 0){
add_column_if_missing <- function(.data, ..., value = 0L){
dots <- rlang::list2(...)
new_cols <- dots[!dots %in% names(.data)]
.data[,unlist(new_cols)] <- value
Expand Down

0 comments on commit b0f554f

Please sign in to comment.