mode_stat: Statistical Mode

Description Usage Arguments Value Examples

View source: R/Summarize.R

Description

Ignoring NAs, find the most common element in a vector (statistical mode). If multiple elements are tied for the mode, the last element in sorted order will be returned, unless all elements are specifically requested, in which case a vector of all modes will be returned.

Usage

1
mode_stat(vec, return_all_modes = FALSE, ignoreBlanks = FALSE)

Arguments

vec

Atomic vector.

return_all_modes

Whether or not to return a vector of all modes (for ties) (logical scalar).

ignoreBlanks

Whether or not to ignore blanks (i.e. NA's and empty strings ("")) (logical scalar).

Value

Scalar of same type as vec, or a vector of the same type if there are multiple modes, and return_all_modes is TRUE.

Examples

1
2
3
4
mode_stat(c(1, 1, 1, 2, 2))
mode_stat(c("a", "b", "b", "b", "c"))
mode_stat(c("a", "b"))
mode_stat(c("a", "b"), return_all_modes = TRUE)

KO112/KO documentation built on Oct. 2, 2020, 9:21 a.m.