corrplot error: arguments imply differing number of rows

Viewed 287

I am trying to generate a correlogram using the rcorr function (hmisc package) and corrplot

library("Hmisc")
library("corrplot")
res2<-rcorr(as.matrix(A), type = "spearman")
corrplot(res2$r, order="AOE", 
         p.mat = res2$P, sig.level = 0.05, insig = "blank")

I get the correlogram, but with an error message: "error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 169, 156" I can`t see anything wrong with the rcorr output. Can anyone help me? Thanks!

1 Answers

In the vignette for package 'corrplot' it says "We can get p-value matrix...by cor.mtest()...". The output of that function produces a p-values matrix with zeroes on the diagonal. The output of rcorr produces a matrix of p-values with NA on the diagonal. Maybe you can just replace your NA diagonal values with zeroes. If you switch to cor.mtest() you'll need to be sure and understand all of its parameters.

Related