mode_count_range {moder} | R Documentation |
Modal count range
Description
mode_count_range()
determines the minimal and maximal number
of modes given the number of missing values.
Usage
mode_count_range(x, max_unique = NULL)
Arguments
x |
A vector to search for its possible modes. |
max_unique |
Numeric or string. If the maximum number of unique values
in |
Details
If x
is a factor, max_unique
should be "known"
or there is a
warning. This is because a factor's levels are supposed to include all of
its possible values.
Value
Integer (length 2). Minimal and maximal number of modes (values tied
for most frequent) in x
.
Examples
# If `NA` is `7` or `8`, that number is
# the only mode; otherwise, both numbers
# are modes:
mode_count_range(c(7, 7, 8, 8, NA))
# Same result here -- `7` is the only mode
# unless `NA` is secretly `8`, in which case
# there are two modes:
mode_count_range(c(7, 7, 7, 8, 8, NA))
# But now, there is now way for `8` to be
# as frequent as `7`:
mode_count_range(c(7, 7, 7, 7, 8, 8, NA))
# The `NA`s might form a new mode here
# if they are both, e.g., `9`:
mode_count_range(c(7, 7, 8, 8, NA, NA))
# However, if there can be no values beyond
# those already known -- `7` and `8` --
# the `NA`s can't form a new mode.
# Specify this with `max_unique = "known"`:
mode_count_range(c(7, 7, 8, 8, NA, NA), max_unique = "known")
[Package moder version 0.2.1 Index]