Learn R Programming

petersenlab (version 1.1.0)

Mode: Statistical Mode.

Description

Calculate statistical mode.

Usage

Mode(x, multipleModes = "all")

Value

Statistical mode(s).

Arguments

x

Numerical vector.

multipleModes

How to handle multiple modes. One of:

  • "mean" = if there are multiple modes, take the mean of all modes

  • "first" = if there are multiple modes, select the first mode

  • "all" = if there are multiple modes, return all modes

Details

Calculates statistical mode(s).

See Also

Examples

Run this code
# Prepare Data
v1 <- c(1, 1, 2, 2, 3)

#Calculate Statistical Mode
Mode(v1)
Mode(v1, multipleModes = "mean")
Mode(v1, multipleModes = "first")

Run the code above in your browser using DataLab