Description Usage Arguments Value Examples
View source: R/soccerxGTimeline.R
Draw a timeline showing cumulative expected goals (xG, excluding penalties and own goals) by two teams over the course of a match, as well as plotting the scoreline and goalscorer at goal events. Currently only works with StatsBomb data but compatability with other (non-StatsBomb) shot data will be added soon.
1 2 3 4 5 6 7 8 | soccerxGTimeline(
df,
homeCol = "red",
awayCol = "blue",
adj = TRUE,
labels = TRUE,
y_buffer = 0.3
)
|
df |
a dataframe containing StatsBomb data from one full match |
homeCol, awayCol |
colours of the home and away team, respectively |
adj |
adjust xG using conditional probability to account for multiple shots per possession |
labels |
include scoreline and goalscorer labels for goals |
y_buffer |
vertical space to add at the top of the y-axis (a quick and dirty way to ensure text annotations are not cropped). |
a ggplot object
1 2 3 4 5 6 7 8 9 10 11 | library(dplyr)
data(statsbomb)
# xG timeline of France vs. Argentina
# w/ goalscorer labels, adjusted xG data
statsbomb %>%
soccerxGTimeline(homeCol = "blue", awayCol = "lightblue", y_buffer = 0.4)
# no goalscorer labels, raw xG data
statsbomb %>%
soccerxGTimeline(homeCol = "blue", awayCol = "lightblue", adj = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.