get_prem_fixture_history: Calculate rolling averages for goals scored for each team...

View source: R/get_prem_fixture_history.R

get_prem_fixture_historyR Documentation

Calculate rolling averages for goals scored for each team home and away for the same fixture over time.

Description

This function returns a breakdown of each team's average points accumulated, goals scored and goals conceded home and away for the same fixture.

Usage

get_prem_fixture_history(
  prem_history = get_prem_history(),
  home_scored_fixtures_lag = 4,
  home_conceded_fixtures_lag = 4,
  away_scored_fixtures_lag = 4,
  away_conceded_fixtures_lag = 4
)

Arguments

prem_history

a data.frame of past fixtures given by get_prem_history()

home_scored_fixtures_lag

The count of lagged games to calculate average home goals scored. Default is 4

home_conceded_fixtures_lag

The count of lagged games to calculate average home goals conceded. Default is 4

away_scored_fixtures_lag

The count of lagged games to calculate average away goals scored. Default is 4

away_conceded_fixtures_lag

The count of lagged games to calculate average away goals conceded. Default is 4

Details

Teams play each other over many seasons and often the outcome follows a certain pattern for e.g. Everton seldom beat Liverpool away. From this we can assess a team's relative attacking and defending strengths in a given fixture over time to use as variables in a model.

Value

This function returns a data.frame with the following columns:

team

Character representing a team in a fixture

fixture

Character represening the fixture i.e. Arsenal v Everton

date

Date when the fixture was played

fthg

Numeric fulltime home goals scored in the fixture

ftag

Numeric fulltime away goals scored in the fixture

form

Numeric running average of points accumulated (3 for a win, 1 for a draw) either home or away

form

sf_scored

Numeric running average of goals scored either home or away

sf_conceded

Numeric running average of goals conceded either home or away

home

Numeric logical represnting whether the team was home or away

Author(s)

Daf Howells <dafhowells@yahoo.co.uk>

Examples

## Not run: 
prem_history <- get_prem_history()
prem_fixture_history_df <- get_prem_fixture_history(prem_history)

## End(Not run)

dafyddhowells/randy documentation built on Nov. 1, 2022, 4:01 p.m.