R/simple_statistics.R

Defines functions dmode

Documented in dmode

#' Mode of a vector x
#'
#' @param x vector of values
#'
#' @return vector (can return multiple maxima)
#' @export
#'
#' @examples
#' dmode(c(2,3,34,2,2))
dmode <- function(x) {
  ux <- unique(x)
  tab <- tabulate(match(x, ux))
  ux[which( tab == max(tab) )]
}
jsilve24/driver documentation built on Jan. 30, 2022, 12:07 p.m.