Skip to content

Commit

Permalink
use player short name from playstats
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Nov 9, 2024
1 parent cb83260 commit 2d7a0e7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/calculate_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ calculate_stats <- function(seasons = nflreadr::most_recent_season(),
stats <- playstats %>%
dplyr::group_by(!!!grp_vars) %>%
dplyr::summarise(

player_name = if (.env$stat_type == "player") custom_mode(.data$player_name, na.rm = TRUE) else NULL,
# Season Type #####################
# if summary level is week, then we have to use the season type variable
# from playstats as it could be REG or POST depending on the value of
Expand Down Expand Up @@ -427,7 +427,7 @@ calculate_stats <- function(seasons = nflreadr::most_recent_season(),
dplyr::left_join(player_info, by = "player_id") %>%
dplyr::select(
"player_id",
# "player_name",
"player_name",
"player_display_name",
"position",
"position_group",
Expand Down
4 changes: 1 addition & 3 deletions data-raw/nfl_stats_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ n_old_3 <- names(s_old_3)

# Differences to old offense stats ----------------------------------------

# player_name -> player_display_name
# recent_team -> team (recent team in weekly data never made sense)
# interceptions -> passing_interceptions (all passing stats have the passing prefix)
# sacks -> sacks_suffered (to make clear it's not on defensive side)
Expand All @@ -45,7 +44,6 @@ setdiff(n2, n_old_1)

# Differences to old defense stats ----------------------------------------

# player_name -> player_display_name
# def_tackles -> there is def_tackles_solo and def_tackles_with_assist
# def_fumble_recovery_own -> fumble_recovery_own (it is not exclusive to defense)
# def_fumble_recovery_yards_own -> fumble_recovery_yards_own (it is not exclusive to defense)
Expand All @@ -60,6 +58,6 @@ setdiff(n2, n_old_2)

# Differences to old kicking stats ----------------------------------------

# player_name -> player_display_name
# No differences
setdiff(n_old_3, n2)
setdiff(n2, n_old_3)
4 changes: 4 additions & 0 deletions data-raw/nfl_stats_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"variable": "player_id",
"description": "GSIS player ID. Available if stat_type = 'player'."
},
{
"variable": "player_name",
"description": "Short player name as listed in play-by-play data. Please keep in mind that this name is not always unique for one player and can change from season to season and sometimes even within a season. Do not group by this variable. Available if stat_type = 'player'."
},
{
"variable": "player_display_name",
"description": "Full name of player. Available if stat_type = 'player'."
Expand Down
Binary file modified data/nfl_stats_variables.rda
Binary file not shown.

0 comments on commit 2d7a0e7

Please sign in to comment.