
Last chance! 50% off unlimited learning
Sale ends in
Sort a correlation matrix based on hclust()
.
cor_sort(x, distance = "correlation", hclust_method = "complete", ...)
A correlation matrix.
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).
Argument passed down into the method
argument of hclust()
.
Other arguments to be passed to or from other functions.
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
Run the code above in your browser using DataLab