| calc_mode | R Documentation |
This function calculates the mode of a given vector and optionally resolves ties using one or two levels of tie-breaks.
calc_mode(x, tie_break = NULL, second_tie_break = NULL)
x |
A character vector for which to find the mode. |
tie_break |
An optional numeric vector used as the first tie-break criterion. |
second_tie_break |
An optional numeric vector used as the second tie-break criterion when the first is insufficient. |
Returns the mode of 'x'. If there are multiple modes and no tie-breaks are specified or they do not resolve the ties, returns "Indeterminate".
data <- c("apple", "apple", "banana", "banana")
tie_break <- c(1, 2, 1, 2)
second_tie_break <- c(1, 1, 2, 1)
calc_mode(data) # Expect: "Indeterminate"
calc_mode(data, tie_break) # Expect: "Indeterminate"
calc_mode(data, tie_break, second_tie_break) # Expect: "banana"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.