| math_mode | R Documentation |
Obtain the most frecuent values (mode) with the frequency from a vector. By default all values with the greatest frequency are returned but you can limit the result to the first one, in lexicographical order.
math_mode(x, remove_na = TRUE, allow_multimodal = TRUE)
x |
( |
remove_na |
( |
allow_multimodal |
( |
A character vector with the most frequent values if allow_multimodal is
TRUE or the first most frequent value (after ordering lexicographically) if
allow_multimodal is FALSE.
The returned vector contains the attribute "frequency" with an integer of
the greatest frequency.
Other categorical_metrics:
accuracy(),
brier_score(),
categorical_summary(),
confusion_matrix(),
f1_score(),
kappa_coeff(),
matthews_coeff(),
pccc(),
pcic(),
pr_auc(),
precision(),
recall(),
roc_auc(),
sensitivity(),
specificity()
## Not run:
# Multimodal
x <- math_mode(c("C", "A", "C", "A"))
# Obtain the greatest frequency
attr(x, "frequency")
# Single mode
x <- math_mode(c("C", "A", "C", "A"), allow_multimodal = FALSE)
# Multimodal
x <- math_mode(iris$Species)
attr(x, "frequency")
values <- c("A", "B", NA, "C", "A", NA, "B")
# Multimodal without NAs
x <- math_mode(values)
# Multimodal with NAs
x <- math_mode(values, remove_na = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.