R/mode_stat.R

Defines functions mode_stat

Documented in mode_stat

#' Mode (Statistical)
#'
#' @description Compute the mode of a numerical or ordinal variable.
#'
#' @param x A numeric vector containing the values whose mode is to be computed.
#'
#'
#' @author D. Schmitz
#'
#' @examples
#' data("data_s")
#'
#' mode_stat(x = data_s$age)
#'
#' @export

mode_stat <- function(x) {

  uniqv <- unique(x)

  uniqv[which.max(tabulate(match(x, uniqv)))]

}
dosc91/SfL documentation built on Sept. 14, 2024, 6:44 a.m.