Returns the mode of a factor or integer
Usage
get_mode(x, na.rm = TRUE, getlast = TRUE, retain_class = TRUE)
Arguments
- x
Vector, factor or integer: Input data.
- na.rm
Logical: If TRUE, exclude NAs (using na.exclude(x)
).
- getlast
Logical: If TRUE, get the last value in case of ties.
- retain_class
Logical: If TRUE, output is always same class as input.
Examples
if (FALSE) { # \dontrun{
x <- c(9, 3, 4, 4, 0, 2, 2, NA)
get_mode(x)
x <- c(9, 3, 2, 2, 0, 4, 4, NA)
get_mode(x)
get_mode(x, getlast = FALSE)
} # }