Wednesday, January 20, 2021

Correlation Matrix

data= read.csv(file.choose())

library(corrplot)

library(RColorBrewer)

library(psych)

data<-cbind(X,Y)

corMat = cor(data, method="spearman")

cor.plot(corMat,numbers=TRUE,colors=TRUE,tl.col="black", tl.srt=45,

         n=51,main=NULL,labels=NULL,

         cex =1.1,

         cex.lab = 0.8,

         cex.axis =0.8, #right side level

         cex.main = 0.8,

         cex.sub = 0.8)


Alternate way
###
corMat = cor(data, method="spearman")
col <- colorRampPalette(c("#BB4444", "#EE9988", "#FFFFFF", "#77AADD", "#4477AA"))
corrplot(corMat, method="color", col=col(200),  
         type="upper", order="hclust", 
         addCoef.col = "black", # Add coefficient of correlation
         tl.col="black", tl.srt=65, #Text label color and rotation
         # hide correlation coefficient on the principal diagonal
         diag=FALSE 
)



0 comments:

Post a Comment