modus: Compute the Mode of a Variable

Description Usage Arguments Details Value Author(s) Examples

Description

Calculate the mode (most frequent value) of a variable

Usage

1
modus(x, randTies = FALSE) 

Arguments

x

a vector

randTies

If TRUE, in case more than one mode is found, one random value of all modes is returned.

Details

The modus function is designed to always return only one value for the mode of a variable. If the variable is bimodal or multimodal, the function returns either NA (if randTies = FALSE) or a randomly chosen value of all modes (if randTies = TRUE).

Value

the mode (most frequent value) of the variable

Author(s)

Martin Hecht

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
x <- c(1, 1, 2, 2)
modus(x)
modus(x, randTies = TRUE)

x <- c(1, NA, NA)
modus(x)

x <- c("x", "x", "y")
modus(x)

## End(Not run)

eatTools documentation built on May 2, 2019, 4:44 p.m.

Related to modus in eatTools...