Calculate the mode of a numeric vector. German name kept to avoid confusion.
modus(x, as_character = TRUE, reduce = TRUE)
A vector with numeric data.
vector
Always return a character. TRUE by default.
TRUE
Since mode can be of length > 1, this option pastes the result into a single character value.
mode
A vector of length 1 of type numeric or character, depending on input.
numeric
character
# 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) # }
Run the code above in your browser using DataCamp Workspace