Learn R Programming

BAwiR (version 1.5)

do_possession_stats: Possessions-related statistics for teams

Description

Compute the possessions-related statistics for teams. These statistics are offensive rating, defensive rating, net rating, pace and number of possessions.

Usage

do_possession_stats(data_possess, season = "2025-2026")

Value

A data frame with the possessions statistics for each team.

Arguments

data_possess

Data frame with the beginning of each possession obtained with do_possession.

season

Season string.

Author

Guillermo Vinue

Details

See https://www.basketball-reference.com/about/glossary.html for formulas and explanations.

Both teams in the same game share the same pace. Pace reflects the tempo of the game itself, not just one team's style. Over many games, a team's average pace reflects how fast they usually play, but any individual game's pace is shared with their opponent.

See Also

do_possession

Examples

Run this code
if (FALSE) {
library(dplyr)
df0 <- acb_vbc_cz_pbp_2223

day_num <- unique(acb_vbc_cz_pbp_2223$day)
game_code <- unique(acb_vbc_cz_pbp_2223$game_code)

# Starting players:
acb_games_2223_sl <- acb_vbc_cz_sl_2223 %>%
  dplyr::filter(period == "1C")

# Prepare data:
df1 <- do_prepare_data(df0, day_num, 
                       acb_games_2223_sl, acb_games_2223_info,
                       game_code)

teams_game <- sort(unique(df1$team))

# Study the lineups:
data_res <- do_study_lineup(df1, day_num, game_code_num, teams_game[1], FALSE) 
data_all_posse <- data_res$data_pos %>% select(-row_num)

# Statistics of possessions:
data_poss_st <- do_possession_stats(data_all_posse, "2022-2023")
}

Run the code above in your browser using DataLab