This function calculates the mode of a given numeric vector.
Source
The source of this function was taken from this
link.
Arguments
- v
A numeric vector. It must not be NULL or empty.
Value
The mode of the vector as a single value. If the vector has a uniform
distribution (all values appear with the same frequency), the function
returns the first value encountered.
Examples
GetMode(c(seq_len(10), 1, 1, 3, 3, 3, 3))
#> [1] 3
GetMode(c(1, 2, 2, 3, 4)) # Returns 2
#> [1] 2
GetMode(c(1, 1, 2, 3, 3)) # Returns 1
#> [1] 1