mode_count {moder} | R Documentation |
Modal count
Description
mode_count()
counts the modes in a vector. Thin wrapper around
mode_all()
.
Usage
mode_count(x, na.rm = FALSE, max_unique = NULL)
Arguments
x |
A vector to search for its modes. |
na.rm |
Boolean. Should missing values in |
max_unique |
Numeric or string. If the maximum number of unique values
in |
Value
Integer. Number of modes (values tied for most frequent) in x
. If
the modes can't be determined because of missing values,
returns NA
instead.
Examples
# There are two modes, `3` and `4`:
mode_count(c(1, 2, 3, 3, 4, 4))
# Only one mode, `8`:
mode_count(c(8, 8, 9))
# Can't determine the number of modes
# here -- `9` might be another mode:
mode_count(c(8, 8, 9, NA))
# Either `1` or `2` could be a
# single mode, depending on `NA`:
mode_count(c(1, 1, 2, 2, NA))
# `1` is the most frequent value,
# no matter what `NA` stands for:
mode_count(c(1, 1, 1, 2, NA))
# Ignore `NA`s with `na.rm = TRUE`
# (there should be good reasons for this!):
mode_count(c(8, 8, 9, NA), na.rm = TRUE)
mode_count(c(1, 1, 2, 2, NA), na.rm = TRUE)
[Package moder version 0.2.1 Index]