R/rescale_minmax.R

Defines functions rescale_minmax

Documented in rescale_minmax

#' Feature scaling: Min-max normalization
#'
#' @param x a numeric vector.
#'
#' @details
#' The formula is as follows:
#' \deqn{
#' X_{scale} = \frac{X_i - X_{min}}{X_{max}-X_{min}}
#' }
#' @examples
#' ## Before rescaling:
#' plot(mtcars$mpg, mtcars$disp)
#' ## After rescaling:
#' plot(rescale_minmax(mtcars$mpg), rescale_minmax(mtcars$disp))
#'
#' @export
rescale_minmax <- function(x) {
  if (is.integer(x)) x <- as.numeric(x)
  .Call(`_RescaleMinMax`, x, PACKAGE = "mmy")
}
strboul/mmy documentation built on Sept. 24, 2021, 12:08 p.m.