Calculate the mode of a numeric vector. German name kept to avoid confusion.

modus(x, as_character = TRUE, reduce = TRUE)

Arguments

x

A vector with numeric data.

as_character

Always return a character. TRUE by default.

reduce

Since mode can be of length > 1, this option pastes the result into a single character value.

Value

A vector of length 1 of type numeric or character, depending on input.

Examples

not_run({ x <- c(1, 2, 6, 2, 1, 5, 7, 8, 4, 3, 2, 2, 2) modus(x) # Or for nominal data x <- structure(c(2L, 1L, 2L, 2L, 2L, 1L), .Label = c("Ja", "Nein"), class = "factor") modus(x) })