mode2 {quest} | R Documentation |
Statistical Mode of a Numeric Vector
Description
mode2
calculates the statistical mode - a measure of central tendancy
- of a numeric vector. This is in contrast to mode
in base R,
which returns the storage mode of an object. In the case multiple modes
exist, the multiple
argument allows the user to specify if they want
the multiple modes returned or just one.
Usage
mode2(x, na.rm = FALSE, multiple = FALSE)
Arguments
x |
atomic vector |
na.rm |
logical vector of length 1 specifying if missing values should
be removed from |
multiple |
logical vector of length 1 specifying if multiple modes
should be returned in the case they exist. If multiple modes exist and
|
Value
atomic vector of the same storage mode as x
providing the
statistical mode(s).
See Also
Examples
# ONE MODE
vec <- c(7,8,9,7,8,9,9)
mode2(vec)
mode2(vec, multiple = TRUE)
# TWO MODES
vec <- c(7,8,9,7,8,9,8,9)
mode2(vec)
mode2(vec, multiple = TRUE)
# WITH NA
vec <- c(7,8,9,7,8,9,NA,9)
mode2(vec)
mode2(vec, na.rm = TRUE)
vec <- c(7,8,9,7,8,9,NA,9,NA,NA)
mode2(vec)
mode2(vec, multiple = TRUE)