Learn R Programming

correlation (version 0.8.0)

cor_sort: 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", ...)

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).

...

Other arguments to be passed to or from other functions.

Examples

Run this code
# NOT RUN {
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