Skip to contents

Generic function for finding the mode, supports multiple modes.

Usage

mode(x, max = FALSE, min = FALSE)

Arguments

x

An R numeric vector object.

max

Boolean Return only the maximum value for mode if there are multiple observed modes. Defaults to FALSE.

min

Boolean Return only the minimum value for mode if there are multiple observed modes. Defaults to FALSE.

Value

The mode, most commonly occurring value in the vector, as a numeric value. In cases where there are more than one mode, all values will be returned by default.

Examples


x <- c(1, 2, 3, 3, 3, 4, 4, 5, 5, 5)
mode(x)
#> [1] 3 5
mode(x, max = TRUE)
#> [1] 5
mode(x, min = TRUE)
#> [1] 3