Learn R Programming

soccermatics (version 0.9.0)

soccerFlipDirection: Flips x,y-coordinates horizontally in one half to account for changing sides at half-time

Description

Normalises direction of attack in both halves of both teams by flipping x,y-coordinates horizontally in either the first or second half; i.e. teams attack in the same direction all game despite changing sides at half-time.

Usage

soccerFlipDirection(dat, pitchLength = 105, pitchWidth = 68,
  period = "period", periodToFlip = 1, x = "x", y = "y")

Arguments

dat

= dataframe containing unnormalised x,y-coordinates

pitchLength, pitchWidth

= length, width of pitch in metres

period

= name of variable containing period labels

periodToFlip

= identity of period to flip

x, y

= name of variables containing x,y-coordinates

Value

a dataframe

Examples

Run this code
# NOT RUN {
# fake period data for tromso dataset, and flip direction of '2nd half'
tromso %>% 
  mutate(period = if_else(t > as.POSIXct("2013-11-07 21:14:00 GMT"), 1, 2))
  soccerFlipDirection(pitchLength = 120, pitchWidth = 80, periodToFlip = 2)

# }

Run the code above in your browser using DataLab