Reputation: 71
I am trying to plot a correlation heatmap by using corrplot package. Details can be found here. But my question is if I want to limit the row and column name where we need the modification?
Row name
mpg cyl disp hp drat
Column name
wt qsec vs am gear carb
Data M = cor(mtcars)
corrplot(M, p.mat = testRes$p, method = 'color', diag = FALSE, type = 'upper', sig.level = c(0.001, 0.01, 0.05), pch.cex = 0.9, insig = 'label_sig', pch.col = 'grey20', order = 'AOE')
Figure should be look like below:
Upvotes: 2
Views: 3375
Reputation: 11076
Here is a partial solution.
library(corrplot)
library(Hmisc) # Computes correlation and p-value matrix
Mp <- rcorr(as.matrix(mtcars))
corrplot(Mp$r[1:5, 6:11], p.mat=Mp$P[1:5, 6:11], method="color", addCoef.col="black")
produces a plot with the correlation coefficients.
corrplot(Mp$r[1:5, 6:11], p.mat=Mp$P[1:5, 6:11], method="color", sig.level = c(0.001, 0.01, 0.05), insig = 'label_sig')
produces a plot that labels the significance of the coefficients. I have not seen a way to combine both so that they do not overprint. Several of your arguments: method = 'color', diag = FALSE, type = 'upper', order = 'AOE' are not appropriate for non-symmetrical plots.
Upvotes: 3