Message-ID: <CA+hbrhVAhn0h5qxfqKUd48kJqKmgnmQtY1qAJEg4YZG66pS1GA@mail.gmail.com>
Date: 2011-08-19T19:38:06Z
From: Peter Langfelder
Subject: display only the top-right half of a correlation matrix?
In-Reply-To: <CABxs9V=vPjb5wHeRFHaH366SjgV=f4BuMm8k9LT1DsDh+LrjVQ@mail.gmail.com>
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