R/door_norm.R

Defines functions door_norm

Documented in door_norm

#' rescale the data values from 0 to 1
#'
#' \code{door_norm} is used to normalize the data in values from 0 to 1.
#'
#'
#' @param x a numeric vector
#' @author Shouwen Ma <\email{shouwen.ma@@uni-konstanz.de}>
#' @author Daniel Münch <\email{daniel.muench@@uni-konstanz.de}>
#' @aliases DoORnorm door_norm
#' @keywords math
#' @export
#' @examples
#' # create example data
#' x <- rnorm(10)
#' 
#' # run door_norm on it
#' door_norm(x)
#'
door_norm <- function(x) {
  if(all(is.na(x)))
     return(x)
  x.max <- max(x, na.rm = TRUE)
  x.min <- min(x, na.rm = TRUE)
  if ((x.max - x.min) == 0) {
    eval <- x - x
  } else {
    eval <- (x - x.min) / (x.max - x.min)
  }
  return(eval)
}
Dahaniel/DoOR.functions documentation built on Feb. 20, 2024, 7:04 p.m.