get_mode: Get the mode of a factor or integer

View source: R/utils.R

get_modeR Documentation

Get the mode of a factor or integer

Description

Returns the mode of a factor or integer

Usage

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

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.

Value

The mode of x

Author(s)

EDG

Examples

x <- c(9, 3, 4, 4, 0, 2, 2, NA)
get_mode(x)
x <- c(9, 3, 2, 2, 0, 4, 4, NA)
get_mode(x)
get_mode(x, getlast = FALSE)

rtemis documentation built on Oct. 20, 2026, 1:06 a.m.