mode_frequency {moder} | R Documentation |
Modal frequency
Description
Call mode_frequency()
to get the number of times that a
vector's mode appears in the vector.
See mode_frequency_range()
for bounds on an unknown frequency.
Usage
mode_frequency(x, na.rm = FALSE, max_unique = NULL)
Arguments
x |
A vector to check for its modal frequency. |
na.rm |
Boolean. Should missing values in |
max_unique |
Numeric or string. If the maximum number of unique values
in |
Details
By default (na.rm = FALSE
), the function returns NA
if any
values are missing. That is because missings make the frequency uncertain
even if the mode is known: any missing value may or may not be the mode,
and hence count towards the modal frequency.
Value
Integer (length 1) or NA
.
See Also
mode_first()
, which the function wraps.
Examples
# The mode, `9`, appears three times:
mode_frequency(c(7, 8, 8, 9, 9, 9))
# With missing values, the frequency
# is unknown, even if the mode isn't:
mode_frequency(c(1, 1, NA))
# You can ignore this problem and
# determine the frequency among known values
# (there should be good reasons for this!):
mode_frequency(c(1, 1, NA), na.rm = TRUE)