leaguetable: Create a league table

Description Usage Arguments Details Value Examples

View source: R/leaguetable.R

Description

Create a table for sports (soccer) leagues by individually defined criteria from a results dataset.

Usage

1
2
3
leaguetable(dataset, home, away, score_home, score_away, date, date_start,
  date_end, matchday, matchday_start, matchday_end, points = c(3, 1, 0),
  rank_by = c("GD", "GF"), HA_display = FALSE, DC_display = FALSE)

Arguments

dataset

A dataset with the results.

home

Name of the home team variable in the dataset as a character string.

away

Name of the away team variable in the dataset as a character string.

score_home

Name of the home team goals variable in the dataset as a character string.

score_away

Name of the away team goals variable in the dataset as a character string.

date

Name of the date variable in the dataset as a character string (optional).

date_start

Earliest date to include if not the earliest date in the dataset as a character string in the format "YY-mm-dd" (optional).

date_end

Last date to include if not the last date in the dataset as character string in the format "YY-mm-dd" (optional).

matchday

Name of the matchday variable in the dataset as a character string (optional).

matchday_start

Earliest matchday to include if not the earliest in the dataset as an integer (optional).

matchday_end

Last matchday to include if not the last in the dataset as an integer (optional).

points

Vector of integers of length three containing the points awarded for wins, draws and losses. Defaults to c(3,1,0).

rank_by

Character vector with the order of arguments to sort the league table following "Pts". Defaults to c("GD","GF").

HA_display

Logical value to indicate whether home and away results should be displayed in the table. Defaults to FALSE.

DC_display

Logical value to indicate whether direct comparison variables from ranking vector should be displayed in the table. Defaults to FALSE.

Details

Mandatory input is a dataset with match results and the names of the variables for home and away team and their respective scored goals.

List of abbreviations:

Possible ranking criteria are:

as well as any of the above with the appendix "_DC", for example Pts_DC or GD_DC, which will applied as ranking criteria for teams with an equal number of points (Pts).

Please be aware that ranking for all criteria is done with descending order. So GA or L can technically be used for ranking, but will result in nonsensical results.

Further optional parameters are the point rewards for wins, draws and losses,the display of additional columns with separate home and away tables and the dates and matchdays to be used for calculation.

If a date range and a matchday range are set, the subset of matches that fit both selection criteria will be used for calculation.

Value

League table in the form of a data.frame.

Examples

1
2
3
4
5
#league table for La Liga 94/95 with three point rewards (instead of two) and home and away results
require(engsoccerdata)
leaguetable(dataset=engsoccerdata::spain[which(engsoccerdata::spain$Season==1994),],
home="home", away="visitor",score_home="hgoal", score_away="vgoal", date="Date",
points = c(3,1,0), rank_by = c("Pts_DC","GD_DC","GF_DC","GD","GF"), DC_display = TRUE)

TouRnament documentation built on Oct. 5, 2019, 9:05 a.m.