Eliminate Diagonal from corrplot Correlation Matrix Plot in R (Example Code)
In this R tutorial you’ll learn how to delete the diagonal from a correlation matrix graphic.
Creation of Example Data
data(iris) # Load example data iris_cor <- cor(iris[ , 1:4]) # Prepare example data iris_cor # Display correlation matrix # Sepal.Length Sepal.Width Petal.Length Petal.Width # Sepal.Length 1.0000000 -0.1175698 0.8717538 0.8179411 # Sepal.Width -0.1175698 1.0000000 -0.4284401 -0.3661259 # Petal.Length 0.8717538 -0.4284401 1.0000000 0.9628654 # Petal.Width 0.8179411 -0.3661259 0.9628654 1.0000000 |
data(iris) # Load example data iris_cor <- cor(iris[ , 1:4]) # Prepare example data iris_cor # Display correlation matrix # Sepal.Length Sepal.Width Petal.Length Petal.Width # Sepal.Length 1.0000000 -0.1175698 0.8717538 0.8179411 # Sepal.Width -0.1175698 1.0000000 -0.4284401 -0.3661259 # Petal.Length 0.8717538 -0.4284401 1.0000000 0.9628654 # Petal.Width 0.8179411 -0.3661259 0.9628654 1.0000000
Example: Removing the Diagonal from a Correlation Matrix Graphic
install.packages("corrplot") # Install corrplot package library("corrplot") # Load corrplot |
install.packages("corrplot") # Install corrplot package library("corrplot") # Load corrplot
corrplot(iris_cor, # Correlation matrix plot without diagonal diag = FALSE) |
corrplot(iris_cor, # Correlation matrix plot without diagonal diag = FALSE)
Further Resources & Related Tutorials
Here, you can find some further resources on topics such as missing data and matrices.