scoredifference {BasketballAnalyzeR} | R 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 |
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 |
team_data |
dataframe, contains several data regarding the teams in the NBA. Inside this function it is used only to check if |
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 ofteam_name
and the score of the opposite team (seedetails
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
## Not run:
PbP <- PbPmanipulation(PbP.BDB)
PbP <- scoredifference(PbP, team_name="GSW", player_data=Pbox, team_data=Tadd)
## End(Not run)