Mode: Compute the mode of a vector

Description Usage Arguments Details Value Author(s) Source Examples

View source: R/Mode.R

Description

Compute the mode of a vector

Usage

1
Mode(x, na.rm = F)

Arguments

x

Vector of which to compute the mode

na.rm

Whether to ignore NA's

Details

If there are several modes, the one occuring first in the data will be returned. No binning is attempted for numeric vectors.

Value

Most frequent value occuring in the vector

Author(s)

Ken Williams

Source

http://stackoverflow.com/a/8189441/3498910

Examples

1
2
3
4
5
6
# x will contain lots of 'a'
x <- sample(letters, prob=c(10, rep(1, 25)), size=100, replace=T)
Mode(x) # will be 'a' (with probability 1-2.4e-15)

x <- rnorm(10)
Mode(x)

antoine-sachet/customFunctions documentation built on Sept. 25, 2020, 8:56 p.m.