Description Usage Arguments Examples
View source: R/soccerPositionMap.R
Draws the average x,y-positions of each player from one or both teams on a soccer pitch.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | soccerPositionMap(
df,
lengthPitch = 105,
widthPitch = 68,
fill1 = "red",
col1 = NULL,
fill2 = "blue",
col2 = NULL,
labelCol = "black",
homeTeam = NULL,
flipAwayTeam = TRUE,
label = c("name", "number", "none"),
labelBox = TRUE,
shortNames = TRUE,
nodeSize = 5,
labelSize = 4,
arrow = c("none", "r", "l"),
theme = c("light", "dark", "grey", "grass"),
title = NULL,
subtitle = NULL,
source = c("manual", "statsbomb"),
x = "x",
y = "y",
id = "player_id",
name = "player_name",
team = "team_name"
)
|
df |
a dataframe containing x,y-coordinates of player position and a player identifier variable |
lengthPitch, widthPitch |
numeric, length and width of pitch in metres |
fill1, fill2 |
character, fill colour of position points of team 1, team 2 (team 2 |
col1, col2 |
character, border colour of position points of team 1, team 2 (team 2 |
labelCol |
character, label text colour |
homeTeam |
if |
flipAwayTeam |
flip x,y-coordinates of away team so attacking from right to left |
label |
type of label to draw, player names ( |
labelBox |
add box around label text |
shortNames |
shorten player names to display last name as label |
nodeSize |
numeric, size of position points |
labelSize |
numeric, size of labels |
arrow |
optional, adds team direction of play arrow as right ( |
theme |
draws a |
title, subtitle |
optional, adds title and subtitle to plot |
source |
if |
x, y, id, name, team |
names of variables containing x,y-coordinates, unique player ids, player names, and team names, respectively; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | library(dplyr)
data(statsbomb)
# average player position from tracking data for one team
# w/ jersey numbers labelled
data(tromso)
tromso %>%
soccerPositionMap(label = "number", id ="id",
labelCol = "white", nodeSize = 8,
arrow = "r", theme = "grass",
title = "Tromso IL (vs. Stromsgodset, 3rd Nov 2013)",
subtitle = "Average player position (1' - 16')")
# transform x,y-coords, standarise column names,
# average pass position for one team using 'statsbomb' method
# w/ player name as labels
statsbomb %>%
soccerTransform(method='statsbomb') %>%
filter(type.name == "Pass" & team.name == "France" & period == 1) %>%
soccerPositionMap(source = "statsbomb",
fill1 = "blue", arrow = "r", theme = "light",
title = "France (vs Argentina, 30th June 2018)",
subtitle = "Average pass position (1' - 45')")
# transform x,y-coords, standarise column names,
# average pass position for two teams using 'manual' method
# w/ player names labelled
statsbomb %>%
soccerTransform(method='statsbomb') %>%
soccerStandardiseCols(method='statsbomb') %>%
filter(event_name == "Pass" & period == 1) %>%
soccerPositionMap(fill1 = "lightblue", fill2 = "blue",
title = "Argentina vs France, 30th June 2018",
subtitle = "Average pass position (1' - 45')")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.