Learn R Programming

BAwiR (version 1.3.4)

do_possession: Compute when possessions start

Description

Compute when the possession starts for each team during each period of a game.

Usage

do_possession(data, period_sel)

Value

Data frame. This is the meaning of the columns that might not be explanatory by themselves:

  • time_start: Time point when the action starts. time_end: Time point when the action ends. poss_time: Duration of the possession. possession: Indicates when the possession starts. This is encoded with the Spanish word inicio (start, in English). points: Number of points scored from a given action.

Arguments

data

Play-by-play prepared data from a given game.

period_sel

Period of interest. Options can be "xC", where x=1,2,3,4.

Author

Guillermo Vinue

Examples

Run this code
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)

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

df1 <- do_prepare_data(df0, day_num, 
                       acb_games_2223_sl, acb_games_2223_info,
                       game_code)
                       
df2 <- do_possession(df1, "1C")                         
#df2

Run the code above in your browser using DataLab