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

compute_mode

Compute The Mode


Description

Computes the mode (most frequent value) of an atomic vector.

Usage

compute_mode(x, ties_method = "random", na_rm = TRUE)

Arguments

x

(vector()).

ties_method

(character(1))
Handling of ties. One of "first", "last" or "random" to return the first tied value, the last tied value, or a randomly selected tied value, respectively.

na_rm

(logical(1))
If TRUE, remove missing values prior to computing the mode.

Value

(vector(1)): mode value.

Examples

compute_mode(c(1, 1, 1, 2, 2, 2, 3))
compute_mode(c(1, 1, 1, 2, 2, 2, 3), ties_method = "last")
compute_mode(c(1, 1, 1, 2, 2, 2, 3), ties_method = "random")

mlr3misc

Helper Functions for 'mlr3'

v0.10.0
LGPL-3
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Patrick Schratz [aut] (<https://orcid.org/0000-0003-0748-6624>)
Initial release

We don't support your browser anymore

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