mfv: Most frequent value(s)

Description Usage Arguments Details Value References Examples

Description

The function mfv returns the most frequent value(s) (or mode(s)) found in a vector. The function mfv1 returns the first of these values, so that mfv1(x) is identical to mfv(x)[[1L]].

Usage

1
2
3
mfv(x, ...)

mfv1(x, ...)

Arguments

x

Vector of observations (of type numeric, character, factor, or logical).

...

Additional parameters that are currently ignored.

Details

Argument x is to come from a discrete distribution. mfv calls the function tabulate.

Value

The function mfv returns a vector of the same type as x. One should be aware that this vector can be of length > 1, in case of multiple modes. mfv1 is safer in the sense that it always returns a vector of length 1 (the first of the modes found).

References

Examples

1
2
3
4
5
6
7
# Basic examples
mfv(c(3, 4, 3, 2, 2, 1, 2))      # 2
mfv(c(TRUE, FALSE, TRUE))        # TRUE
mfv(c("a", "a", "b", "a", "d"))  # "a"

mfv(c("a", "a", "b", "b", "d"))  # c("a", "b")
mfv1(c("a", "a", "b", "b", "d")) # "a"

statoo documentation built on Jan. 27, 2017, 1 p.m.