Learn R Programming

rtemis (version 1.4.3)

mode_value: Mode of a vector

Description

Returns the most frequent value of a vector.

Usage

mode_value(x, na.rm = TRUE, getlast = TRUE, retain_class = TRUE)

Value

The mode of x

Arguments

x

Vector, factor or integer: Input data.

na.rm

Logical: If TRUE, exclude NAs (using na.exclude(x)).

getlast

Logical: If TRUE, get the last value in case of ties.

retain_class

Logical: If TRUE, output is always same class as input.

Author

EDG

Examples

Run this code
x <- c(9, 3, 4, 4, 0, 2, 2, NA)
mode_value(x)
x <- c(9, 3, 2, 2, 0, 4, 4, NA)
mode_value(x)
mode_value(x, getlast = FALSE)

Run the code above in your browser using DataLab