Description Usage Arguments Details Value Author(s) References Examples
Plots scoring probability of shots as a function of a given variable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
data |
a data frame whose rows are shots and with the following columns: |
var |
character, the string giving the name of the numerical variable according to which the scoring probability is estimated. Available options: |
shot.type |
character, the type of shots to be analyzed; available options: |
players |
subset of players to be displayed (optional; it can be used only if the |
bw |
numeric, the smoothing bandwidth of the kernel density estimator (see ksmooth). |
period.length |
numeric, the length of a quarter in minutes (default: 12 minutes as in NBA). |
xlab |
character, x-axis label. |
x.range |
numerical vector or character; available options: |
title |
character, plot title. |
palette |
color palette. |
team |
character; if |
col.team |
character, color of the scoring probability line for all the shots in data. |
legend |
character; if |
The data
data frame could also be a play-by-play dataset provided that rows corresponding to events different from shots have NA
in the ShotType
variable.
Required columns:
result
, a factor with the following levels: "made"
for made shots, "miss"
for missed shots, and ""
for events different from shots
ShotType
, a factor with the following levels: "2P"
, "3P"
, "FT"
(and NA
for events different from shots)
player
, a factor with the name of the player who made the shot
playlength
, a numeric variable with time between the shot and the immediately preceding event
periodTime
, a numeric variable with seconds played in the quarter when the shot is attempted
totalTime
, a numeric variable with seconds played in the whole match when the shot is attempted
shot_distance
, a numeric variable with the distance of the shooting player from the basket (in feet)
A ggplot2
plot
Marco Sandri, Paola Zuccolotto, Marica Manisera (basketballanalyzer.help@unibs.it)
P. Zuccolotto and M. Manisera (2020) Basketball Data Science: With Applications in R. CRC Press.
1 2 3 4 5 | PbP <- PbPmanipulation(PbP.BDB)
PbP.GSW <- subset(PbP, team=="GSW" & result!="")
players <- c("Kevin Durant","Draymond Green","Klay Thompson")
scoringprob(data=PbP.GSW, shot.type="2P", players=players,
var="shot_distance", col.team="gray")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.