R/up.tri.R

Defines functions up.tri

## Extracts the upper left triangle of a quadratic matrix
up.tri <- function(x, diag = TRUE, droplast = FALSE) {
  x <- as.matrix(x)
  res <- (row(x) + col(x)) - 1 <= ncol(x)
  if (!diag) 
    res[(row(x) + col(x) - 1) == ncol(x)] <- FALSE
  if (droplast) 
    res[nrow(res), 1] <- FALSE
  res
}

Try the DNAtools package in your browser

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

DNAtools documentation built on July 8, 2020, 7:13 p.m.