R/rescale.R

Defines functions rescale

Documented in rescale

#' Rescale a vector
#'
#' @param x a numeric vector
#'
#' @return a numeric vector with min 0 and max 1
#'
#' @export
rescale <- function(x) {
  stopifnot(is.numeric(x))
  lower <- min(x)
  upper <- max(x)
  (x - lower) / (upper - lower)
}
jdblischak/ci4r documentation built on Oct. 15, 2019, 10:11 a.m.