R/tr.R

Defines functions `tr`

`tr` <-
function(X) {
  if(is.matrix(X)) y <- sum(diag(X))
  if(is.vector(X)) {
    cat("warning: X is not a matrix\n")
    y <- sum(X)
  }
  return(y)
}

Try the ToolsForCoDa package in your browser

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

ToolsForCoDa documentation built on Sept. 20, 2021, 5:19 p.m.