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

computeMode

Compute statistical mode of a vector (value that occurs most frequently).


Description

Works for integer, numeric, factor and character vectors. The implementation is currently not extremely efficient.

Usage

computeMode(x, ties.method = "random", na.rm = TRUE)

Arguments

x

[vector]
Factor, character, integer, numeric or logical vector.

ties.method

[character(1)]
“first”, “random”, “last”: Decide which value to take in case of ties. Default is “random”.

na.rm

[logical(1)]
If TRUE, missing values in the data removed. if FALSE, they are used as a separate level and this level could therefore be returned as the most frequent one. Default is TRUE.

Value

Modal value of length 1, data type depends on data type of x.

Examples

computeMode(c(1,2,3,3))

BBmisc

Miscellaneous Helper Functions for B. Bischl

v1.11
BSD_2_clause + file LICENSE
Authors
Bernd Bischl [aut, cre], Michel Lang [aut], Jakob Bossek [aut], Daniel Horn [aut], Jakob Richter [aut], Dirk Surmann [aut]
Initial release

We don't support your browser anymore

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