R/numeric_mode.R

#' Mode of a Numeric Vector
#'
#' Computes the mode of a numeric vector using kernel density estimation.
#'
#' @noRd
#'
#' @param x A numeric vector.
#' @return The computed mode.
#'
numeric_mode <- function(x) {

  object <- stats::density(x, n = 512, na.rm =  TRUE)
  rout <- object$x[which.max(object$y)]
  return(rout)

}
dsnavega/imputeForest documentation built on May 8, 2019, 2:43 p.m.