stat_mode: Statistical Mode

View source: R/utils_mode.R

stat_modeR Documentation

Statistical Mode

Description

Computes the statistical mode, i.e. the value that appears most often in a vector. Returns the first match, if TRUE for multiple values.

Usage

stat_mode(x, ..., na.rm = FALSE)

Arguments

x

A vector of data values.

...

Further arguments, currently unused.

na.rm

a logical evaluating to TRUE or FALSE indicating whether NA values should be stripped before the computation proceeds.

Value

The statistical mode with the same type as the input vector x.

Examples

vector_numeric <- sample(1:5, 15, TRUE)
vector_numeric
stat_mode(vector_numeric)

vector_character <- sample(LETTERS[1:5], 15, TRUE)
vector_character
stat_mode(vector_character)

nflreadr documentation built on Sept. 11, 2024, 6:14 p.m.