modus: Modus

Description Usage Arguments Value Examples

View source: R/misc_stats.R

Description

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

Usage

1
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

1
2
3
4
5
6
7
8
9
## 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)

## End(Not run)

Example output

[1] "2"
[1] "Nein"

tadaatoolbox documentation built on July 2, 2020, 2:30 a.m.