Correlation Corrplot Configuration

匿名 (未验证) 提交于 2019-12-03 01:10:02

问题:

I am newbie in R scripts :-)

I Built a corrplot matrix this way:

corrplot(cor(d1[,2:14], d1[,2:14]), method=c("color"),          bg = "white", addgrid.col = "gray50",           tl.cex=1, type="lower", tl.col = "black",           col = colorRampPalette(c("red","white","blue"))(100)) 

I need show the values of correlation in the lower matrix.. inside the color matrix that i built. how i can do that?

Is it possible exclude the main diagonal from the lower matrix? In this diagonla always we have the perfect correlation :-)

The other doubt.. i wanna show the significant values for the correlation using stars instead of squares. like (*, , *). Is it possible?

Can you help me guys?

回答1:

With a bit of hackery you can do this in a very similar R package, corrgram. This one allows you to easily define your own panel functions, and helpfully makes theirs easy to view as templates. Here's the some code and figure produced:

set.seed(42) library(corrgram)  # This panel adds significance starts, or NS for not significant panel.signif 

The code isn't very clean, as it's mostly patched together functions from the package, but it should give you a good start to get the plot you want. Possibly you can take a similar approach with the corrplot package too.

update: Here's a version with stars and cor on the same triangle:

panel.shadeNtext 

Also commented out is another way of showing significance, it'll bold those below a threshold rather than using stars. Might be clearer that way, depending on what you want to show.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!