cor_sort {correlation}R Documentation

Sort a correlation matrix to improve readability of groups and clusters

Description

Sort a correlation matrix based on hclust().

Usage

cor_sort(x, distance = "correlation", hclust_method = "complete", ...)

Arguments

x

A correlation matrix.

distance

How the distance between each variable should be calculated. If correlation (default; suited for correlation matrices), the matrix will be rescaled to 0-1 (distance = 0 indicating correlation of 1; distance = 1 indicating correlation of -1). If raw, then the matrix will be used as a distance matrix as-is. Can be others (euclidean, manhattan, ...), in which case it will be passed to dist() (see the arguments for it).

hclust_method

Argument passed down into the method argument of hclust().

...

Other arguments to be passed to or from other functions.

Examples

x <- correlation(mtcars)

cor_sort(as.matrix(x))
cor_sort(x, hclust_method = "ward.D2") # It can also reorder the long form output
cor_sort(summary(x, redundant = TRUE)) # As well as from the summary

[Package correlation version 0.8.5 Index]