A heatmap uses color to communicate relationships between data values. A simple heatmap provides an immediate visual summary of information and allows the user to understand complex datasets. In this recipe, we will continue to use the mtcars_cor matrix from the previous recipe and use ggplot2 for visualization along with plotting a heatmap over geospatial data.
Creating heatmaps
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)] <- NA
return(cormat)
}
get_upper_triangle <- function(cormat){
cormat[lower.tri(cormat)]<- NA
return(cormat)
}
> reorder_cormat...