Skip to content

Instantly share code, notes, and snippets.

@smach
Created February 28, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smach/fd804e6fad8f15530acd to your computer and use it in GitHub Desktop.
Save smach/fd804e6fad8f15530acd to your computer and use it in GitHub Desktop.
Useful data visualization of a correlation matrix, code from the R Graphics Cookbook by Winston Chang
# Function takes a correlation matrix from the cor() function and outputs a visualization.
# The corrplot package must be installed.
# This code comes from the R Graphics Cookbook by Winston Chang
corrviz <- function(mycorrmatrix){
col <- colorRampPalette(c("#BB4444", "#EE9988", "#FFFFFF", "#77AADD", "#4477AA"))
corrplot::corrplot(mycorrmatrix, method="shade", shade.col=NA, tl.col="black", tl.srt=45, col=col(200), addCoef.col="black")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment