pracma (version 1.9.9)

Mode: Mode function (Matlab style)

Description

Most frequent value in vector or matrix

Usage

Mode(x)

Arguments

x
Real or complex vector or of factor levels.

Value

One element from x and of the same type. The number of occurrences will not be returned.

Details

Computes the `sample mode', i.e. the most frequently occurring value in x.

Among values occurring equally frequently, Mode() chooses the smallest one (for a numeric vector), one with a smallest absolute value (for complex ones) or the first occurring value (for factor levels).

A matrix will be changed to a vector.

See Also

median

Examples

Run this code
x <- round(rnorm(1000), 2)
Mode(x)

Run the code above in your browser using DataLab