Description Usage Arguments Value See Also Examples
A flow field to show the mean angle and distance of passes in zones of the pitch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
df |
dataframe of event data containing fields of start x,y-coordinates, pass distance, and pass angle |
lengthPitch, widthPitch |
numeric, length and width of pitch in metres. |
xBins, yBins |
integer, the number of horizontal (length-wise) and vertical (width-wise) bins the soccer pitch is to be divided up into; if |
x, y, angle, distance |
names of variables containing pass start x,y-coordinates, angle, and distance |
col |
colour of arrows |
lwd |
thickness of arrow segments |
arrow |
adds team direction of play arrow as right ( |
title, subtitle |
adds title and subtitle to plot; NULL by default |
theme |
palette of pitch background and lines, either |
plot |
base plot to add path layer to; NULL by default |
a ggplot object of a heatmap on a soccer pitch
soccerHeatmap
for drawing a heatmap of player position, or soccerSpokes
for drawing spokes to show all directions in each area of the pitch.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(dplyr)
data(statsbomb)
# transform x,y-coords, filter only France pass events,
# draw flow field showing mean angle, distance of passes per pitch zone
statsbomb %>%
soccerTransform(method = 'statsbomb') %>%
filter(team.name == "France" & type.name == "Pass") %>%
soccerFlow(xBins=7, yBins=5,
x="location.x", y="location.y", angle="pass.angle", distance="pass.length")
# transform x,y-coords, standarise column names,
# filter only France pass events
my_df <- statsbomb %>%
soccerTransform(method = 'statsbomb') %>%
soccerStandardiseCols(method = 'statsbomb') %>%
filter(team_name == "France" & event_name == "Pass")
# overlay flow field onto heatmap showing proportion of team passes per pitch zone
soccerHeatmap(my_df, xBins=7, yBins=5) %>%
soccerFlow(my_df, xBins=7, yBins=5, plot = .)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.