Generic function for finding the mode, supports multiple modes.
Arguments
- x
An R numeric
vectorobject.- max
BooleanReturn only the maximum value for mode if there are multiple observed modes. Defaults toFALSE.- min
BooleanReturn only the minimum value for mode if there are multiple observed modes. Defaults toFALSE.- na.rm
BooleanRemove missing values before finding the mode. Defaults toTRUE.
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)
stats_mode(x)
#> [1] 3 5
stats_mode(x, max = TRUE)
#> [1] 5
stats_mode(x, min = TRUE)
#> [1] 3