most_freq: Calculate most frequently occuring value in a vector

Description Usage Arguments Value References Examples

View source: R/stat-funs.R

Description

Calculate most frequently occuring value in a vector (statistical mode).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
most_freq(x, ...)

## S3 method for class 'numeric'
most_freq(x, ...)

## S3 method for class 'character'
most_freq(x, ...)

## S3 method for class 'factor'
most_freq(x, ...)

Arguments

x

a vector.

...

additional parameters passed on to table.

Value

a scalar equal to the modal value of x. If x is multimodal, length(x) will equal the number of unique modes in x.

References

http://mathworld.wolfram.com/Mode.html

Examples

1
2
3
4
5
6
7
8
x <- c(0, 1, 2, 3, 4, 5, 0)
y <- c("foo", "bar", "baz", "foo")
z <- factor(y)
most_freq(x)
most_freq(y)
most_freq(z)
xx <- c(1, x)
most_freq(xx)

sboysel/boysel documentation built on May 29, 2019, 3:24 p.m.