majority: Determines the most common element(s)

Description Usage Arguments Examples

Description

Determines the most common element(s)

Usage

1
2
majority(x, use_mode = TRUE, return_single = TRUE, na.rm = FALSE,
  seed = NULL)

Arguments

x

A numeric vector.

use_mode

A logical indicating whether to use modeest::mfv if suitable.

return_single

A logical indicating whether a single value should return even if several elements of x are the most common. If so, then one will be picked at random.

na.rm

A logical value indicating whether NA values should be stripped before the computation proceeds.

seed

An integer value or NULL to set the random number generator. NULL follows the behavior of set.seed.

Examples

1
2
3
4
5
6
7
8
9
x1 <- c(rep(NA, 3), 1:4)
x2 <- c(rep(1/3, 3), 1:4, rep(NA, 3))
majority(x1)
majority(x1, na.rm = TRUE)
majority(x1, return_single = FALSE, na.rm = TRUE)
majority(x1, use_mode = FALSE, return_single = FALSE, na.rm = TRUE)
majority(x1, use_mode = FALSE, return_single = TRUE, na.rm = TRUE)
majority(x1, use_mode = FALSE, return_single = FALSE, na.rm = FALSE)
majority(x2, return_single = FALSE)

dschlaep/ecotoner documentation built on May 15, 2019, 2:57 p.m.