How to hide selected correlations for corrplot?

我们两清 提交于 2020-01-02 03:37:12

问题


I am new to coding and R. I was trying to visualize a correlation matrix using corrplot, but don't want to show all the correlation values. I wish to hide/cancel a chunk of selected columns and rows correlation values, so only an inverted 'L' of values are shown.

As an example, see edited image of an example corrplot here:


回答1:


Set those entries you want blank in the plot to NA in the correlation matrix (or a copy of it) and then set the argument na.label=" " in the call to corrplot.




回答2:


exclude these columns by using indexes, for example

M <- cor( mtcars[ , -c(1, 3, 6)] )
corrplot(M, method = "ellipse")

where we exclude columns 1, 3, 6 (variables mpg, disp, cyl). Other way would be specifying which columns should be evaluated

mtcars[ , c(2:4, 7) ]

takes into account columns 2, 3, 4 and 7. Go through some R tutorial for beginners to familiarize yourself with coding conventions.



来源:https://stackoverflow.com/questions/23213754/how-to-hide-selected-correlations-for-corrplot

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