display only the top-right half of a correlation matrix?
On Fri, Aug 19, 2011 at 12:32 PM, Liviu Andronic <landronimirc at gmail.com> wrote:
On Fri, Aug 19, 2011 at 9:02 PM, Peter Langfelder <peter.langfelder at gmail.com> wrote:
Use as.dist: here's an example.
Seems promising, but for one issue: I would like to keep the diagonal and thus specify 'diag=T', but then as.dist() replaces the diagonal values with zero. (See below.) Is there a way to prevent it from doing that? Either keep the original values, or not display anything in the diagonal (as for the upper part)?
if as.dist doesn't work, use brute force: x = matrix(rnorm(5*100), 100, 5) mat = signif(cor(x), 2); mat[lower.tri(mat)] = "" data.frame(mat) Peter