首页 > 解决方案 > Add significant correlations to corrplot graph in R

问题描述

For my data I made a correlation plot. I want to visualize the correlations with the color method. Additionaly I would like to add the correlation coefficient, however, I only want to visualize them for the significant correlations, in all other cases I would like to show a cross.

This is what I have done:

GM_young <- replicate(6, rnorm(11))
colnames(GM_young2) <- c('PA_rest','FL-rest','MW_rest','PA_con','FL_con', 'MW_con')

corrGM_young<-cor(GM_young) #  gives you a matrix with correlations
p.mat <- cor.mtest(GM_young) # matrix of the p-value of the correlation

# make corrplot
corrplot(corrGM_young, method = "color", type="lower",order = "hclust", p.mat = p.mat, sig.level = 0.01, diag=FALSE , tl.col="black",tl.cex = 0.8, cl.cex = 0.8,cl.ratio=0.3,tl.srt = 45, title="Gastrocnemius Young", mar=c(0,0,2,0), addCoef.col = TRUE)

enter image description here

However, now I get the coefficients for all the correlations. I only want to visualize the 0.74. The other boxes I want to visualize using the colors and the cross as they are not significant.

Can someone help me with this? Thank you

标签: r

解决方案


推荐阅读