Search code examples
rr-corrplotpearson-correlation

How to create the pearson correlation matrix in correct view


I have an easy question. I try to obtain the pearson correlation usng R (corrplot package). I obtain the correct matrix but I want to obatin the number only in the part down the principal diagonal with the number 1.

I use this script:

cor(Dati_Rsoftware[,1:17], method=c('pearson'))
###Correlation calculation###

library(corrplot)
Bisznia = cor(Dati_Rsoftware[,1:17], method=c('pearson'))
corrplot(Bisznia)
###Matrix###

Thanks for helping. Jo


Solution

  • Using the toy data set iris, load the package:

    library(corrplot)
    
    iris_cor <- cor(iris[,1:4], method = c("pearson"))
    corrplot(iris_cor, method = "circle", type = "upper")
    

    the output is the following one: enter image description here

    the argument type="upper" is the key to plot only the circles that are upper than principle diagonal.