diving: Calculation of diving scores

divingR Documentation

Calculation of diving scores

Description

Functions to implement four ways to calculate the points awarded for a dive in a diving competition, including the way that is used in the Olympic Games.

Usage

dmean(
  x,
  DD = "DD",
  scores = paste0("J", 1:7),
  trim = 2/7,
  replace = TRUE,
  reorder = TRUE
)

dmedian(
  x,
  DD = "DD",
  scores = paste0("J", 1:7),
  type = 6,
  replace = TRUE,
  reorder = TRUE
)

dmode(x, DD = "DD", scores = paste0("J", 1:7), replace = TRUE, reorder = TRUE)

tables(x, type = 1, diverRanks = 1)

Arguments

x

A numeric matrix or data frame, ideally of the same format as daley.

DD

A character (or numeric) scalar giving the column name (or number) of x that contains the DD (degree of difficulty) values of each dive. The default is set up to work with the data in daley.

scores

A character (or numeric) vector giving the column names (or numbers) of x that contain the 7 scores for each dive. The default is set up to work with the data in daley.

trim

Only relevant to divemean. Passed to mean. The default, trim = 2 / 7, corresponds to the calculation using in diving competitions.

replace

A logical scalar. If replace = FALSE then a vector of the dive points is returned. If replace = TRUE then the DivePoints, DiveRank, TotalPoints, OverallRank and PointsBehind columns are updated in light of the new values of the dive points and this data frame is returned. If any of these named columns do not exist then the returned object is the same as the replace = FALSE case.

reorder

A logical scalar. If replace = TRUE then reorder determines whether the order of the divers is changed to reflect the new values of TotalPoints at the end of the competition.

type

Determines the form of a data frame returned as a summary table.

  • type = 0: Rank, Name, NOCcode (Country), TotalPoints at the end of the competition.

  • type = 1: DD, J1-J7 and dive points (those already in x).

  • type = 2: like type = 1 but gives dive points, and points based on the mean, median and mode.

  • type = 3: like type = 2 but gives only the total points accumulated over the competition, ordered by dive points.

  • type = 4: like type = 3 but totals are replaced by ranks.

diverRanks

The ranks of the divers that should be included in a table. For example, diverRanks gives the medalists.

Details

In the default case, e.g. dmean(daley), the 2 smallest and 2 largest scores of the 7 scores are removed; the sum of the 3 remaining scores is calculated; and the result is multiplied by the dive's degree of difficulty.

Another way to think of this is that we take the sample mean of the 3 middle scores, then multiply by 3, then multiply by the degree of difficulty.

In the dmean(daley, trim = 0) case we take the sample mean of all 7 scores, then multiply by 3, then multiply by the degree of difficulty. That is, we do not trim the 2 smallest and 2 largest values.

Similarly, in the dmedian(daley) and dmode(daley) cases we take the sample median or mode, respectively, of all 7 scores, then multiply by 3, then multiply by the degree of difficulty. If there is more than one sample mode then we use the sample mean of these modes.

Value

A numeric vector dive points if replace = FALSE or x does not have appropriately named columns. Otherwise, a dataframe of the same structure as x in which the columns DivePoints, DiveRank, TotalPoints, OverallRank and PointsBehind have been updated in light of the new dive points values.

See Also

daley for Tokyo 2020 Olympics Diving Men's Individual 10m platform final results

Examples

# The calculation used in competitions (trimmed sample sums)
dmean(daley, replace = FALSE)

# An equivalent calculation without trimming
dmean(daley, replace = FALSE, trim = 0)

# An equivalent calculation based on a sample median
dmedian(daley, replace = FALSE)

# An equivalent calculation based on a sample mode
dmode(daley, replace = FALSE)

paulnorthrop/stat0002 documentation built on Oct. 10, 2024, 1:27 p.m.