I woult like to corrplot my data (the package I use, surprise surprise, is {corrplot}) and display the p-values of the pairwise correlations in it.
Now I found some useful stuff here on how to do exactly that and at first glance, it went surprisingly well. But then I noticed that the p-values were completely strange and they didn't correspond to the actual p-values from cor.test().
I already found out (using exemplary data) that it's not due to my data, but something I got wrong about the code with which I'm trying to include the p-values.
So here's a reproducible example:
#using built-in r-data:
data("mtcars")
#now for the corrplot:
M = cor(mtcars, use="complete.obs")
pval <- corr.test(M, adjust="none")$p
corrplot(M, method = "color", type = "upper",
order = "original", tl.col = "black", tl.srt = 45,
family="serif", p.mat=pval, insig="p-value", sig.level=0)
This is what I get:
(didn't let me upload the file, so you have to click the link...)
Anyway, to illustrate that these are not the actual p-values, let's take juts one pair, namely "qsec" and "drat":
cor.test(mtcars$qsec, mtcars$drat, use="complete.obs")
And the resulting p-value ("p-value = 0.6196") is definitely not the one you see in the corrplot ("0.14").
This is probably really stupid and I'm sure (p<.0001) that I'm overlooking something - but I don't know what it is. Help?