[R] display only the top-right half of a correlation matrix?

Liviu Andronic landronimirc at gmail.com
Fri Aug 19 20:50:48 CEST 2011


Dear all
Is there an easy way to display only one half (top-right or
bottom-left) of a correlation matrix?

> require(Hmisc)
> rcorr(as.matrix(mtcars[ , 1:4]))
       mpg   cyl  disp    hp
mpg   1.00 -0.85 -0.85 -0.78
cyl  -0.85  1.00  0.90  0.83
disp -0.85  0.90  1.00  0.79
hp   -0.78  0.83  0.79  1.00

n= 32


P
     mpg cyl disp hp
mpg       0   0    0
cyl   0       0    0
disp  0   0        0
hp    0   0   0


Since the two sides are identical, there is little value in having
both displayed at the same time. Moreover, it considerably slows down
the inspection of the results.

Thank you
Liviu



-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail



More information about the R-help mailing list