Tools for visualisation and analysis of soccer spatiotemporal data
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

soccermatics

soccermatics provides tools to visualise spatial tracking and event data from football (soccer) matches. There are currently functions to visualise shot maps and expected goals, passing diagrams, heatmaps of player position, flow fields of passing or movement direction, average formation, and individual player trajectories.

Many more functions are planned - see To Do List, suggestions are welcomed!

The sample x,y-coordinate data in tromso and tromso_extra were made available by Pettersen et al. (2014), whilst event data has been kindly made public by StatsBomb.

Use of the name soccermatics kindly permitted by the eponymous book's author, David Sumpter.

soccermatics is built on R v3.4.2.


Installation

You can install soccermatics from GitHub in R using devtools:

if (!require("devtools")) install.packages("devtools")
devtools::install_github("jogall/soccermatics")

library(soccermatics)

Updates

The package is getting a makeover over the next few months and may occassionally break during this time. Should installation fail during this time, please install the latest stable version (v0.8.4) from this tarball like so:

install.packages("https://github.com/JoGall/soccermatics/blob/master/soccermatics_0.8.4.tar.gz", repo=NULL, type="source")

Usage and samples

Below are some sample visualisations produced by soccermetrics. See the package manual pdf or the individual help files for each function (e.g. ?soccerHeatmap) for more information and example code.

Figure 1. Shot map of Manchester City WFC (vs. Chelsea LFC, 2018-02-24; data made available by StatsBomb) showing xG and shot outcome. Made using soccerShotmap().

Figure 2. Pass map of Manchester City WFC (vs. Chelsea LFC, 2018-02-24; data made available by StatsBomb) showing pass origin origin (circles), path (lines) and outcome. Made using soccerPassmap().

Figure 3. Average position of Tromsø IL players (vs. Strømsgodset, 2013-11-03). Made using soccerPositions().

Figure 4. Average position of Manchester City WFC (dark blue) and Chelsea LFC (sky blue) players (2018-02-24). Made using soccerPositions().

Figure 5. Player heatmap over 90 minutes (player #8; Tromsø IL vs. Anzhi, 2013-11-07). Bins are appromximately 5m x 5m; arrow shows direction of play. Made using soccerHeatmap().

Figure 6. Movement path of one player over 120 seconds (player #9; Tromsø IL vs. Strømsgodset, 2013-11-03). Made using soccerPath().

Figure 7. Movement path of 3 players over 15 minutes (Tromsø IL vs. Strømsgodset, 2013-11-03). Made using soccerPath().

Figure 8. Flow visualisation showing average player movement in different areas of the pitch (player #9; Tromsø IL vs. Strømsgodset, 2013-11-03). Made using soccerFlow().

Figure 9. Spoke map of all movement events in each pitch bin (player #8; Tromsø IL vs. Anzhi, 2013-11-07). This figure uses a random sample of player movement, but this method is intended to visualise pass or shot event data which are not yet publicly available. Made using soccerSpokes().