get_xg_fixture_history: Calculate rolling averages expected goals (xG) scored for...

View source: R/get_xg_fixture_history.R

get_xg_fixture_historyR Documentation

Calculate rolling averages expected goals (xG) scored for each team home and away

Description

This function returns a breakdown of each team's rolling average xG for and against both home and away.

Usage

get_xg_fixture_history(
  home_scored_games_lag = 4,
  home_conceded_games_lag = 4,
  away_scored_games_lag = 4,
  away_conceded_games_lag = 4
)

Arguments

home_scored_games_lag

The count of lagged games to calculate average home xG. Default is 4,

home_conceded_games_lag

The count of lagged games to calculate average home xG against. Default is 4,

away_scored_games_lag

The count of lagged games to calculate average away xG. Default is 4,

away_conceded_games_lag

The count of lagged games to calculate average away xG against. Default is 4,

Value

This function returns a data.frame with the following columns

date

Date when the fixture was played

team

Character representing a team in a fixture

fixture

Character represening the fixture e.g Arsenal v Everton

actual_score

Character represening the actual score in the fixture e.g. 2-1

xg1

Numeric fulltime home xG in the fixture

xg2

Numeric fulltime away xG in the fixture

home

Logical represening whether or not the team was home or away in the fixture

xg_for

Numeric showing running average of xG for the team

xg_against

umeric showing running average of xG against the team

Author(s)

Daf Howells <dafhowells@yahoo.co.uk>

Examples

## Not run: 
xg_fixture_history_df <- get_xg_fixture_history()

## End(Not run)

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