[R] Selective subsetting

2006-11-10 Thread Davendra Sohal
Hi all, Here's an interesting (for me, at least!) problem I came across: I have a correlation matrix, let's say with 6 variables, A to F, as column headings and the same 6 as row headings. The matrix is filled with correlation coefficients. Therefore, the diagonal is all 1's, and each of the two

Re: [R] Selective subsetting

2006-11-10 Thread Benilton Carvalho
A=matrix(1:9,3) A[lower.tri(A)] b On Nov 10, 2006, at 4:50 PM, Davendra Sohal wrote: Hi all, Here's an interesting (for me, at least!) problem I came across: I have a correlation matrix, let's say with 6 variables, A to F, as column headings and the same 6 as row headings. The matrix is

Re: [R] Selective subsetting

2006-11-10 Thread Dimitrios Rizopoulos
try this: cor.mat - cor(iris[1:4]) cor.mat[lower.tri(cor.mat)] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax:

Re: [R] Selective subsetting

2006-11-10 Thread Francisco Zagmutt
Look at the functions tril() and triu() in the Matrix package Regards Francisco Davendra Sohal wrote: Hi all, Here's an interesting (for me, at least!) problem I came across: I have a correlation matrix, let's say with 6 variables, A to F, as column headings and the same 6 as row headings.