mode_all | R Documentation |
mode_all()
returns the set of all modes in a vector.
mode_all(x, na.rm = FALSE)
x |
A vector to search for its modes. |
na.rm |
Boolean. Should missing values in |
A vector with all modes (values tied for most frequent) in x
. If
the modes can't be determined because of missing values,
returns NA
instead.
mode_first()
for the first-appearing mode.
mode_single()
for the only mode, or NA
if there are more.
# Both `3` and `4` are the modes:
mode_all(c(1, 2, 3, 3, 4, 4))
# Only `8` is:
mode_all(c(8, 8, 9))
# Can't determine the modes here --
# `9` might be another mode:
mode_all(c(8, 8, 9, NA))
# Either `1` or `2` could be a
# single mode, depending on `NA`:
mode_all(c(1, 1, 2, 2, NA))
# `1` is the most frequent value,
# no matter what `NA` stands for:
mode_all(c(1, 1, 1, 2, NA))
# Ignore `NA`s with `na.rm = TRUE`
# (there should be good reasons for this!):
mode_all(c(8, 8, 9, NA), na.rm = TRUE)
mode_all(c(1, 1, 2, 2, NA), na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.