R/statistical_mode.R

Defines functions statistical_mode

Documented in statistical_mode

#' @title Statistical mode of a vector
#' @description Computes the mode of a numeric or character vector
#' @param x Numeric or character vector.
#' @return Statistical mode of `x`.
#' @examples
#'
#' statistical_mode(x = c(10, 9, 10, 8))
#'
#' @rdname statistical_mode
#' @family utilities
#' @export
statistical_mode <- function(x) {
  x.unique <- unique(x)

  x.unique[which.max(tabulate(match(x, x.unique)))]
}

Try the spatialRF package in your browser

Any scripts or data that you put into this service are public.

spatialRF documentation built on Dec. 20, 2025, 1:07 a.m.