Computes the statistical mode, i.e. the value that appears most often in a vector. Returns the first match, if TRUE for multiple values.
Examples
vector_numeric <- sample(1:5, 15, TRUE)
vector_numeric
#> [1] 3 1 2 1 4 1 4 1 2 2 4 2 4 5 3
stat_mode(vector_numeric)
#> [1] 1
vector_character <- sample(LETTERS[1:5], 15, TRUE)
vector_character
#> [1] "D" "A" "E" "A" "E" "A" "A" "E" "B" "E" "C" "A" "D" "B" "A"
stat_mode(vector_character)
#> [1] "A"