scoredifference: Computes the score difference between the two teams in the...

View source: R/scoredifference.R

scoredifferenceR Documentation

Computes the score difference between the two teams in the match

Description

Computes the score difference between the two teams in the match

Usage

scoredifference(PbP_data, team_name, player_data, team_data)

Arguments

PbP_data

a play-by-play data frame, previously handled by PbPmanipulation

team_name

name of the team we are interested in. The name can be either shortened (e.g. CLE) or extended (e.g. Cleveland Cavaliers)

player_data

dataframe containing the boxscore data of all players of a particula season. We need it to know the players who have played at least one match for a team during the season. This dataframe might be substituted by a dataframe which has a column Player containing in each row the name of the players and a second columd Team containing the extended name (e.g. Golden State Warriors) of the team in which the player has played at least one match. If a player has played at least one match for more than one team during the same season, he/she will have a row for each franchise where has played

team_data

dataframe, contains several data regarding the teams in the NBA. Inside this function it is used only to check if team_name corresponds to a team in the NBA. If the teams in the play-by-play data studied are the same as in the 2017-18 season, Tadd (the dataframe contained in the BasketballAnalyzeR package, regarding the 2017-18 season) can be used

Details

The score difference computed by the function can be different from the simple difference between the score of the home team and the one of the away team, as we have to take account of the points scored during an action. Indeed, the value of score.diff indicates the difference in the score while the action was played

Value

the initial play-by-play dataframe, with two additional columns:

  • score.diff: difference between the score of team_name and the score of the opposite team (see details for more informations)

*isHome: boolean which indicates if team_name is the home team in that play-by-play row

Author(s)

Andrea Fox

References

P. Zuccolotto and M. Manisera (2020) Basketball Data Science: With Applications in R. CRC Press.

P. Zuccolotto, M. Manisera and M. Sandri (2018) Big data analytics for modeling scoring probability in basketball: The effect of shooting under high pressure conditions. International Journal of Sports Science & Coaching.

Examples

PbP <- PbPmanipulation(PbP.BDB)
PbP <- scoredifference(PbP, team_name="GSW", player_data=Pbox, team_data=Tadd)

sndmrc/BasketAnalyzeR documentation built on June 6, 2023, 12:52 a.m.