form_fixture_history_league_position: Combine past form and fixture history with league position

View source: R/form_fixture_history_league_position.R

form_fixture_history_league_positionR Documentation

Combine past form and fixture history with league position

Description

Joins team averages for goals and form with past fixture history and also calculates a team's league position.

Usage

form_fixture_history_league_position(
  form_and_fixture_history = join_form_and_fixture_history()
)

Arguments

form_and_fixture_history

A data.frame of joined form and fixture history given by join_form_and_fixture_history()

Details

In addition to the average goals scored and conceded by a team both in recent games and in the same fixture, we would also want to know that's team's league position at the time that the fixture was played. This function joins form and past fixture data frames and calculates the cumulative points for each team after each game within each season.

Value

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

team

Character values for the team

fixture

Character represening the fixture i.e. Arsenal v Everton

date

Character values for the date that the match was played

fthg

Numeric fulltime home goals scored in the fixture

ftag

Numeric fulltime away goals scored in the fixture

ftag

form

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

form

scored

Numeric running average of goals scored either home or away

conceded

Numeric running average of goals conceded either home or away

home

Numeric logical represnting whether the team was home or away

win

Numeric logical represnting whether the team won the fixture

draw

Numeric logical represnting whether the team drew the fixture

sf_scored

Numeric running average of goals scored either home or away

sf_conceded

Numeric running average of goals conceded either home or away

season

Character representing the premier league season

points

Numeric representing the points gained by the team in the fixture

cum_points

Numeric representing the cumulative points gained by the team after n games in the season

game

Numeric representing the game count. A team will play 38 games in the modern era of the premier league

league_pos

Numeric representing a team's league position after n games in a season

Author(s)

Daf Howells <dafhowells@yahoo.co.uk>

Examples

## Not run: 
df <- join_form_and_fixture_history()
form_fixture_history_league_position <- form_fixture_history_league_position(df)

## End(Not run)

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