R/mode.R

#' Return mode of a vector of values
#'
#' Function that return mode that works for both numeric & character/factor data:
#'
#' @param x A vector of values
#'
#' @return A float number or string of characters that representing values presented
#'         most frequently in the vector
#' @export
#'
#' @examples
#' coord_estimate <- mode(alf_gps$coord_rd)
mode <- function(x) {
  ux <- unique(x)
  ux[ which.max( tabulate(match(x, ux)) ) ]
}
hongqi0314/PRAuto.PMML documentation built on May 6, 2019, 11:30 a.m.