O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

Define helper functions to reorder the correlation matrix and identify hidden patterns in the matrix using hierarchical clustering:

> get_lower_triangle<-function(cormat){cormat[upper.tri(cormat)] <- NAreturn(cormat)}get_upper_triangle <- function(cormat){cormat[lower.tri(cormat)]<- NAreturn(cormat)}> reorder_cormat <- function(cormat){# Use correlation between variables as distancedd <- as.dist((1-cormat)/2)hc <- hclust(dd)cormat <-cormat[hc$order, hc$order]}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required