diving | R Documentation |
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.
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)
x |
A numeric matrix or data frame, ideally of the same format as
|
DD |
A character (or numeric) scalar giving the column name (or number)
of |
scores |
A character (or numeric) vector giving the column names (or
numbers) of |
trim |
Only relevant to |
replace |
A logical scalar. If |
reorder |
A logical scalar. If |
type |
Determines the form of a data frame returned as a summary table.
|
diverRanks |
The ranks of the divers that should be included in a
table. For example, |
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.
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.
daley
for Tokyo 2020 Olympics Diving Men's
Individual 10m platform final results
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.