tadaatoolbox (version 0.16.0)

modus: Modus

Description

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

Usage

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

Run this code
# 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