This function returns the mode of a vector. If the vector contains a character or factor, the most common character/factor is returned. Numbers written as characters will be compatible with non-character numbers (i.e. doubles/numeric), but the function returns a character.

Modes(x)

Arguments

x

vector from which to retrieve the mode from.

Value

same class as 'x'.

See also

tabulate()

Examples

Modes(x = c(1, 1, 3, 0, 2, 4, 2, 1, 5, 2, 1))
#> [1] 1
Modes(x = c('a','b', 'c', 'a', 'c', 'a'))
#> [1] "a"
Modes(x = c('a', 2, 'x', 7895, 1, '2', 't', 2, 1))
#> [1] "2"