R/normalize.R

Defines functions normalize

Documented in normalize

normalize <- function(data)
  {
    ### data - a matrix or xts object 

    if (missing(data)) { stop("please, specify data") }
    if (! is.matrix(data)) 
      { 
        data <- as.matrix(data)
        warning("data should be a matrix, the function tried to convert data to a matrix") 
      }

    x <- data
    for (i in 1:ncol(data))
      {
        x[,i] <- (data[,i]-min(data[,i]))/(max(data[,i])-min(data[,i]))
      }
    rownames(x) <- rownames(data)
    colnames(x) <- colnames(data)
    
    return(x)
  }
  

Try the fDMA package in your browser

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

fDMA documentation built on July 26, 2023, 6:09 p.m.