R/tri.R

Defines functions bottom_tri

Documented in bottom_tri

#' Function
#' 
#' @export
bottom_tri <- function(x, diag=TRUE){
   x <- as.matrix(x)
   
   if(diag){
      col(x)- 1 + row(x) -1 > nrow(x) ##-1 Since the first column is the row name
   }else col(x)- 1 + row(x)> nrow(x) ##-1 Since the first column is the row name
}
"bottom_tri<-" <- function(x, diag=TRUE, value){
   x[bottom_tri(x, diag=diag)] <- value
   return(x)
}
m-montero/LDTr documentation built on May 21, 2019, 9:17 a.m.