Learn R Programming

nflreadr (version 1.4.1)

stat_mode: 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)

Value

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

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab