[R] blank upper or lower triangle of cor-matrix

Leo Gürtler leog at anicca-vijja.de
Wed Feb 7 19:35:52 CET 2007


Dear altogether,

I want to blank the lower (or upper) part of a correlation matrix as it 
is done by dist()

example:

( d <- cor(matrix(runif(12),nrow=4)) )

If I do the following

d[lower.tri(d)] <- ""

of course everything is changed to character - that's not what should be.
Additionally, it does not work to assign "0" or anything else. The same 
is true for assigning "NA".

However, what I want is like the following:

( dist(matrix(runif(12),nrow=4)) )

Looking into dist(), it seems that the calculation and the matrix are 
done in C and not in plain R.

How can I realize it?

thanks!

best,

leo



More information about the R-help mailing list