mode_frequency_range() determines the minimum and maximum
number of times that a vector's mode appears in the vector. The minimum
assumes that no NAs are the mode; the maximum assumes that all NAs are.
Arguments
- x
A vector to check for its modal frequency.
- max_unique
Numeric or string. If the maximum number of unique values in
xis known, setmax_uniqueto that number. This rules out thatNAs represent values beyond that number (see examples). Set it to"known"instead if no values beyond those already known can occur. Default isNULL, which assumes no maximum.
Details
If there are no NAs in x, the two return values are identical.
If all x values are NA, the return values are 1 (no two x values
are the same) and the total number of values (all x values are the same).
See also
mode_frequency(), for the precise frequency (or NA if it can't
be determined).
Examples
# The mode is `7`. It appears four or
# five times because the `NA` might
# also be a `7`:
mode_frequency_range(c(7, 7, 7, 7, 8, 8, NA))
#> [1] 4 5
# All of `"c"`, `"d"`, and `"e"` are the modes,
# and each of them appears twice:
mode_frequency_range(c("a", "b", "c", "c", "d", "d", "e", "e"))
#> [1] 2 2