Calculate the mode (modal value) and return a label

modal(x, na.rm = TRUE)

Arguments

x

A vector

na.rm

If TRUE missing values are removed before calculation

Details

From https://www.tutorialspoint.com/r/r_mean_median_mode.htm

Examples

modal(c("a", "b", "b"))
#> [1] "b"
modal(c(1:10, 5))
#> [1] 5
modal(as.factor(c(letters, "b")))
#> [1] b #> Levels: a b c d e f g h i j k l m n o p q r s t u v w x y z
modal(runif(100) > 0.5)
#> [1] TRUE