Correlogram with Question Marks Along the Diagonal

149 Views Asked by At

I did a correlation analysis in R and have a correlation matrix with only the p-values. I created the correlogram for only the significant p-values(<0.05) using this p-values matrix. However, my correlogram has question marks along the diagonal. I know this is due to the fact that my correlation matrix has "NA" along the diagonal. Is there anyway I can get corrplot to ignore the NAs in my correlation matrix? I have included my code and correlogram below.

corrplot(data_corr$P, order = "hclust", type = "upper",
         tl.col = "black", tl.srt = 45,  sig.level=0.05, tl.cex = 0.3)

Correlogram Below

1

There are 1 best solutions below

0
SAL On BEST ANSWER

You can first replace missing (NA) values with 0 (diag(data_corr$P) <- 0) then plot the p-values matrix. But a better option would be to add diag=F option within corrplot():

library(corrplot)   
corrplot(data_corr$P
, order = "hclust"
, type = "upper"
, tl.col = "black"
, tl.srt = 45
, sig.level=0.05
, tl.cex = 0.3
, diag=FALSE
)