| nba_tracking_aggregate | R Documentation |
Fetches leaguedashptstats dashboards for each combination of seasons
and season_types, then aggregates the results by entity
(PLAYER_ID for Player, TEAM_ID for Team) following the contract
ported from sportsdataverse-py's aggregate_tracking_frames:
Identity columns (*_ID, *_NAME, *_ABBREVIATION, and any other
non-numeric string column such as TEAM_CITY) are carried via first()
— never summed.
*_FG_PCT / *_FT_PCT are recomputed from the summed FGM/FGA and
FTM/FTA denominators (denom 0 -> NA); a *_FG_PCT / *_FT_PCT column
whose makes/attempts pair is absent is dropped rather than recomputed.
Other *_PCT columns (e.g., DRIVE_PTS_PCT — "% of total" rates)
are dropped from the output because they are not additive.
All remaining numeric columns are summed (numeric-content gate,
mirroring the sportsdataverse-py dtype.is_numeric() rule).
nba_tracking_aggregate(
seasons,
season_types = "Regular Season",
per_mode = "Totals",
pt_measure_type = "Drives",
player_or_team = "Player",
league_id = "00",
...
)
seasons |
Character vector of NBA season strings, e.g.
|
season_types |
Character vector of season type(s), e.g.
|
per_mode |
Per-mode string passed to |
pt_measure_type |
Tracking measure type string, e.g. |
player_or_team |
|
league_id |
League identifier string. Default |
... |
Additional arguments forwarded to |
Aggregate NBA Player-Tracking Stats Across Multiple Seasons
nba_tracking_aggregate(seasons = c("2022-23", "2023-24"),
pt_measure_type = "Drives",
player_or_team = "Player")
A data.frame (tibble-compatible) with one row per entity
(PLAYER_ID or TEAM_ID). Count columns are summed across all
requested seasons/season types; *_FG_PCT and *_FT_PCT are
recomputed from summed numerators/denominators; *_PCT "% of total"
columns are dropped; identity string columns are carried from the
first season. Returns a 0-row frame when no data are available.
Designed and validated for COUNT-based tracking measures (e.g.
"Drives"). Rate-only columns without a _pct suffix in some
pt_measure_type values are summed across seasons (a known limitation
shared with the sportsdataverse reference engine); verify aggregation
semantics before using rate-heavy measures.
Saiem Gilani
Other NBA Player Tracking Functions:
nba_boxscoretraditionalv2(),
nba_leaguedashoppptshot(),
nba_playerdashboardbyclutch(),
nba_teamdashboardbyclutch()
try({
df <- nba_tracking_aggregate(
seasons = c("2022-23", "2023-24"),
pt_measure_type = "Drives",
player_or_team = "Player"
)
print(df[1:5, c("PLAYER_ID", "PLAYER_NAME", "DRIVES", "DRIVE_FG_PCT")])
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.