Learn R Programming

soccermatics (version 0.8.4)

soccerPositions: Plot average player position on a soccer pitch.

Description

Draws the average x,y-positions of all players in a dataframe and plots over a soccer pitch.

Usage

soccerPositions(df, id_var = "id", lengthPitch = 105, widthPitch = 68,
  col1 = "red", col2 = "white", size = 8, grass = FALSE, plot = NULL)

Arguments

df

dataframe containing x,y-coordinates of player position in columns named 'x' and 'y'.

id_var

character, the name of the column containing player identity. Defaults to 'id'.

lengthPitch, widthPitch

numeric, length and width of pitch in metres.

col1

character, fill colour of position points.

col2

character, border colour of position points.

size

numeric, size of position points and text.

grass

if TRUE, draws pitch background in green and lines in white. If FALSE, draws pitch background in white and lines in black.

See Also

soccerPitchBG for a background soccer pitch for the purpose of drawing position maps, player trajectories, etc..

Examples

Run this code
# NOT RUN {
data(tromso)
# draw average player position of players
p <- soccerPositions(tromso, lengthPitch = 105, widthPitch = 68, grass = TRUE)
# draw arrow showing direction of play
soccerDirection(p, "right", lengthPitch = 105, widthPitch = 68, grass = TRUE)

# }

Run the code above in your browser using DataLab