R/scale_minmax.R

Defines functions scale_minmax

Documented in scale_minmax

#' Scale a vector to the range \[0, 1\]
#'
#' @param x A numeric vector
#' @return A numeric vector scaled to the range \[0, 1\]
#' @export
#'
#' @examples
#' scale_minmax(c(1, 2, 3))
scale_minmax <- function(x) {
  minx <- min(x, na.rm = TRUE)
  maxx <- max(x, na.rm = TRUE)
  (x - minx) / (maxx - minx)
}

Try the funkyheatmap package in your browser

Any scripts or data that you put into this service are public.

funkyheatmap documentation built on April 11, 2025, 5:39 p.m.