R/gNormalize.R

Defines functions gNormalize

Documented in gNormalize

gNormalize <- function(data)
  {
    ### data - a matrix or xts object of, for example, Google Trends

    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:nrow(data))
      {
        x[i,] <- data[i,] / sum(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.