mode-possible {moder} | R Documentation |
Possible sets of modes
Description
mode_possible_min()
and mode_possible_max()
determine the
minimal and maximal sets of modes from among known modes, given the number
of missing values.
Usage
mode_possible_min(x, multiple = FALSE)
mode_possible_max(x, multiple = FALSE)
Arguments
x |
A vector to search for its possible modes. |
multiple |
Boolean. If |
Value
By default, a vector with the minimal or maximal possible sets of
modes (values tied for most frequent) in x
. If the functions can't
determine these possible modes because of missing values, they return
NA
by default (multiple = FALSE
).
See Also
mode_count_range()
for the minimal and maximal numbers of
possible modes. They can always be determined, even if the present
functions return NA
.
Examples
# "a" is guaranteed to be a mode,
# "b" might also be one, but
# "c" is impossible:
mode_possible_min(c("a", "a", "a", "b", "b", "c", NA))
mode_possible_max(c("a", "a", "a", "b", "b", "c", NA))
# Only `8` can possibly be the mode
# because, even if `NA` is `7`, it's
# still less frequent than `8`:
mode_possible_min(c(7, 7, 8, 8, 8, 8, NA))
mode_possible_max(c(7, 7, 8, 8, 8, 8, NA))
# No clear minimal or maximal set
# of modes because `NA` may tip
# the balance between `1` and `2`
# towards a single mode:
mode_possible_min(c(1, 1, 2, 2, 3, 4, 5, NA))
mode_possible_max(c(1, 1, 2, 2, 3, 4, 5, NA))
# With `multiple = TRUE`, the functions
# return all values that might be part of
# the min / max sets of modes; not these
# sets themselves:
mode_possible_min(c(1, 1, 2, 2, 3, 4, 5, NA), multiple = TRUE)
mode_possible_max(c(1, 1, 2, 2, 3, 4, 5, NA), multiple = TRUE)