Reorder the correlation matrix according to the correlation coefficient by using hclust for hierarchical clustering order. This is useful to identify the hidden pattern in the matrix.

reorder_cormat(x)

Arguments

x

The correlation matrix

Value

The ordered correlation matrix

Author

Tiago Olivoto tiagoolivoto@gmail.com

Examples

# \donttest{ library(metan) cor_mat <- corr_coef(data_ge2, PH, EH, CD, CL, ED, NKR) cor_mat$cor
#> PH EH CD CL ED NKR #> PH 1.0000000 0.9318282 0.3153910 0.3251648 0.6613148 0.3530495 #> EH 0.9318282 1.0000000 0.2805118 0.3971935 0.6302561 0.3310529 #> CD 0.3153910 0.2805118 1.0000000 0.3003636 0.3897128 0.5933206 #> CL 0.3251648 0.3971935 0.3003636 1.0000000 0.6974629 -0.1149405 #> ED 0.6613148 0.6302561 0.3897128 0.6974629 1.0000000 0.2220727 #> NKR 0.3530495 0.3310529 0.5933206 -0.1149405 0.2220727 1.0000000
reorder_cormat(cor_mat$cor)
#> CD NKR PH EH CL ED #> CD 1.0000000 0.5933206 0.3153910 0.2805118 0.3003636 0.3897128 #> NKR 0.5933206 1.0000000 0.3530495 0.3310529 -0.1149405 0.2220727 #> PH 0.3153910 0.3530495 1.0000000 0.9318282 0.3251648 0.6613148 #> EH 0.2805118 0.3310529 0.9318282 1.0000000 0.3971935 0.6302561 #> CL 0.3003636 -0.1149405 0.3251648 0.3971935 1.0000000 0.6974629 #> ED 0.3897128 0.2220727 0.6613148 0.6302561 0.6974629 1.0000000
# }