R/normM.R

Defines functions normM

Documented in normM

#' @title Normalize function for a matrix
#' 
#' @description 
#' To calculate normmalize of a matrix
#' 
#' @param X a numeric matrix
#' @return a matrix with norm 1
#' @export
#' @keywords internal
normM <- function(X){
  
  if (is.data.frame(X) == TRUE) {
    X = as.matrix(X)
  }
  
  normX = sqrt(sum(diag(t(X) %*% X)))
  Y     = X / normX 
  return(Y)
}

Try the multigroup package in your browser

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

multigroup documentation built on March 26, 2020, 5:50 p.m.