lyqgoh
lyqgoh

Reputation: 61

How to hide selected correlations for corrplot?

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:

enter image description here

Upvotes: 6

Views: 5811

Answers (2)

GregRG
GregRG

Reputation: 21

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.

Upvotes: 2

Pafnucy
Pafnucy

Reputation: 628

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.

Upvotes: 0

Related Questions