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

2011-08-19 Thread Liviu Andronic
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 disphp 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

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

2011-08-19 Thread Jean V Adams
r-help-boun...@r-project.org wrote on 08/19/2011 01:50:48 PM: [image removed] [R] display only the top-right half of a correlation matrix? Liviu Andronic to: r-help@r-project.org Help 08/19/2011 01:55 PM Sent by: r-help-boun...@r-project.org Dear all Is there an easy

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

2011-08-19 Thread Peter Langfelder
On Fri, Aug 19, 2011 at 11:50 AM, Liviu Andronic landronim...@gmail.com wrote: 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

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

2011-08-19 Thread Liviu Andronic
On Fri, Aug 19, 2011 at 9:02 PM, Peter Langfelder peter.langfel...@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

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

2011-08-19 Thread Peter Langfelder
On Fri, Aug 19, 2011 at 12:32 PM, Liviu Andronic landronim...@gmail.com wrote: On Fri, Aug 19, 2011 at 9:02 PM, Peter Langfelder peter.langfel...@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',

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

2011-08-19 Thread Liviu Andronic
On Fri, Aug 19, 2011 at 9:38 PM, Peter Langfelder peter.langfel...@gmail.com wrote: 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) Yes, brute force works. This isn't quite how I wanted to do this,