R/reorder_cormat.R

Defines functions reorder_cormat

Documented in reorder_cormat

#' Reorder Correlation Matrix by correlation
#'
#' @param cormat
#'
#' @return matrix
#' @export reorder_cormat
#'
#' @examples
#' cormat <- round(cor(mtcars), 2)
#' reorder_cormat(cormat)
reorder_cormat <- function(cormat){
  # Use correlation between variables as distance
  dd <- as.dist((1-cormat)/2)
  hc <- hclust(dd)
  cormat <-cormat[hc$order, hc$order]
}
bradisbrad/olfatbones documentation built on May 29, 2020, 9:54 p.m.