R/get_mode.R

Defines functions get_mode

Documented in get_mode

#' Get the mode of a vector
#'
#' @param x a vector
#'
#' @return Mode of x
#' @export


get_mode <- function(x) {
  values <- unique(stats::na.omit(x))
  values[which.max(tabulate(match(x, values)))]
}
CCMH-PSU/CCMHr documentation built on Jan. 31, 2024, 1:08 a.m.