R/utils.R

Defines functions vectorizing_fun

Documented in vectorizing_fun

#' Vectorizing a Matrix.
#'
#' @param a A matrix
#' @return A vectorized matrix, a vector.
#' @export
vectorizing_fun <- function(x){

  # 'x' is a matrix

  x[!lower.tri(x)] <- NA # Filling the upper part of the triangle with NA's
  x <- as.vector(x) # Making the matrix a vector
  res <- x[!is.na(x)] # Taking out the NA's
  return(res) # returning only the lower triangle part of the matrix
}
Martins6/distgeomodel documentation built on Nov. 12, 2020, 5:35 p.m.