Skip to contents

Loads the nba_stats_rolling_windows release: every shooter's rolling form over his last window_n field-goal attempts (metric = "fg_pct") and three-point attempts ("fg3_pct"), for window_n 50 and 200, computed from load_nba_stats_shots(). One row per player per window unit per window size. Windows count attempts, not games, and cross season boundaries: cur is the make rate over the last n attempts through the season, prev the window before it, season_start the window entering the season and career_baseline every attempt before cur's window (each NA rather than partial without a full window of history). delta_prev_rank is 1 for the biggest riser among qualified rows.

Usage

load_nba_stats_rolling_windows(
  seasons = most_recent_nba_stats_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

Arguments

seasons

A vector of 4-digit years – the season's START year (e.g. 2024 for the 2024-25 season). Published coverage starts at 1996 (1996-97). Pass seasons = TRUE for every published season.

...

Additional arguments passed to an underlying function that writes the season data into a database.

dbConnection

A DBIConnection object, as returned by DBI::dbConnect()

tablename

The name of the data table within the database

Value

A hoopR_data tibble with one row per entity per metric per window.

col_nametypesdescription
seasonintegerEND year of the NBA season (2025 = 2024-25), the asset's own stamp: one more than the seasons argument.
entity_typecharacterWhich aggregate the row is: "league" (every counted attempt that season), "team" or "player" on metric_curves; always "player" on rolling_windows.
entity_idcharacterstats.nba.com id of the entity as TEXT – the team_id on a team row, the person_id on a player row, NA on the league row.
entity_namecharacterLabel for the entity: the team tricode ("GSW") on a team row, the shooter's name as the pbp ships it on a player row; NA on the league row.
team_idcharacterstats.nba.com team id (e.g. 1610612737 = Atlanta Hawks).
metriccharacterWhat the row measures: "fg_pct_by_shot_distance" on metric_curves (field-goal percentage by shot distance in feet); "fg_pct" (window_unit "fga") or "fg3_pct" (window_unit "fg3a") on rolling_windows.
window_unitcharacterWhat the window counts: "fga" (every field-goal attempt) or "fg3a" (three-point attempts). Regular-season and playoff attempts only.
window_nintegerWindow size in attempts (50 or 200), not games.
curnumericMake rate over the player's last n attempts through the season (the current window).
prevnumericMake rate over the window_n attempts just before the current window; NA unless that whole window exists.
season_startnumericMake rate over the window_n attempts just before the season began (form entering the season); NA unless the career before the season holds a full window.
career_baselinenumericMake rate over every career attempt (since 1996-97) before the current window, earlier games of this season included; NA unless that history holds at least window_n attempts.
delta_prevnumericcur - prev; NA when either side is NA.
delta_seasonnumericcur - season_start; NA when either side is NA.
delta_careernumericcur - career_baseline; NA when either side is NA.
delta_prev_rankintegerRank of delta_prev within (window_unit, window_n, metric), 1 = biggest riser, ties share the lowest rank; NA unless the row is qualified and has a prev.
nintegerAttempts the current window averages: window_n, or fewer for a career shorter than the window.
qualifiedlogicalTRUE when n == window_n (a full window, not a short career). Filter on it before ranking or comparing players.
last_event_dateDateDate of the player's latest counted attempt through the season.
as_of_dateDateDate of the latest counted attempt league-wide that season: the date the windows are current through.
id_sourcecharacterNamespace of entity_id / team_id on this row – "nba_stats" here; the cross-league contract carries "espn", "gsis" and "wnba_stats" elsewhere.

Examples

# \donttest{
  try(load_nba_stats_rolling_windows(seasons = most_recent_nba_stats_season()))
#> ───────────────────────────────────────────────────────────────── hoopR 3.2.0 ──
#> # A tibble: 1,728 × 21
#>    season entity_type entity_id entity_name team_id  metric window_unit window_n
#>     <int> <chr>       <chr>     <chr>       <chr>    <chr>  <chr>          <int>
#>  1   2027 player      1626145   Jones       1610612… fg3_p… fg3a              50
#>  2   2027 player      1626157   Towns       1610612… fg3_p… fg3a              50
#>  3   2027 player      1626162   Oubre Jr.   1610612… fg3_p… fg3a              50
#>  4   2027 player      1626164   Booker      1610612… fg3_p… fg3a              50
#>  5   2027 player      1626167   Turner      1610612… fg3_p… fg3a              50
#>  6   2027 player      1626168   Lyles       1610612… fg3_p… fg3a              50
#>  7   2027 player      1626171   Portis Jr.  1610612… fg3_p… fg3a              50
#>  8   2027 player      1626181   Powell      1610612… fg3_p… fg3a              50
#>  9   2027 player      1626204   Nance Jr.   1610612… fg3_p… fg3a              50
#> 10   2027 player      1626209   Hezonja     1610612… fg3_p… fg3a              50
#> # ℹ 1,718 more rows
#> # ℹ 13 more variables: cur <dbl>, prev <dbl>, season_start <dbl>,
#> #   career_baseline <dbl>, delta_prev <dbl>, delta_season <dbl>,
#> #   delta_career <dbl>, delta_prev_rank <int>, n <int>, qualified <lgl>,
#> #   last_event_date <date>, as_of_date <date>, id_source <chr>
# }