Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

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.

Value

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

Note

In Matlab/Octave an array dimension can be selected along which to find the mode value; this has not been realized here.

Shadows the R function mode that returns essentially the type of an object.

See Also

Examples

x <- round(rnorm(1000), 2)
Mode(x)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.