R/normalize.R

Defines functions normalize

Documented in normalize

#' Use this function to normalize your data to a specific range
#'
#' Normalize your data
#'
#' @param x A vector with numeric values
#'
#' @return A vector with min-max normalized values
#' @export
#'
#' @examples
#' data(whisky_collection)
#' whisky_collection$RATING <- normalize(whisky_collection$RATING)
normalize <- function(x) {
  df <- as.numeric((x - min(x, na.rm = TRUE))/(max(x, na.rm = TRUE) - min(x, na.rm = TRUE)))
    return(df)
}
dominikjung42/dstools documentation built on June 16, 2024, 2:40 a.m.