Mode: Mode

View source: R/stats.R

ModeR Documentation

Mode

Description

Returns the mode of a vector. First in a tie wins (see examples).

Usage

Mode(x, na.rm = FALSE)

Arguments

x

A vector.

na.rm

Remove missing values before calculating the mode (FALSE by default). NAs are counted just like any other element. That is, an NA in the vector won't necessarily result in a return NA. See the first example.

Value

The mode of the input vector.

Examples

Mode(c(1,2,2,3,3,3, NA))
Mode(c(1,2,2,3,3,3, NA), na.rm=TRUE)
Mode(c(1,2,2,3,3,3, NA, NA, NA, NA))
Mode(c(1,2,2,3,3,3, NA, NA, NA, NA), na.rm=TRUE)
Mode(c("A", "Z", "Z", "B", "B"))


stephenturner/Tmisc documentation built on April 21, 2024, 8:31 a.m.