Learn R Programming

soccermatics (version 0.9.0)

soccerFlipHoriz: 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

soccerFlipHoriz(dat, periodVar = "period", periodToFlip = 1,
  pitchLength = 105, pitchWidth = 68)

Arguments

dat

= dataframe containing unnormalised x,y-coordinates named `x` and `y`

periodVar

= name of variable containing period labels

periodToFlip

= which period to flip

pitchLength, pitchWidth

= length, width of pitch in metres

Value

a dataframe

Examples

Run this code
# NOT RUN {
# to flip coordinates in 2nd half of a dataframe with 1st/2nd half identity 
# labelled by variable named `period`
soccerFlipHoriz(df, "period", 2, 105, 68)

# }

Run the code above in your browser using DataLab