[R] Matrix operations please help

Srinivas Iyyer srini_iyyer_bio at yahoo.com
Mon Oct 31 07:56:39 CET 2005


Dear Group, 

I have a matrix  (157 X 157 ) with correlation values.
I want to convert the unique elements into a long list
so that I can add an extra variable and plot them. 

Example:

      A   B   C   D 

alfa 1   0.3  0.8  -0.3

beta 0.2  1  -0.3  0.4

echo 0.9 -0.3  1   0.5

tang -0.5 0.5  0.4  1


I want to convert into this form:


alfa  A  1
alfa  B  0.3
alfa  C  0.8
alfa  D  -0.3
beta  A 0.2
beta  B 1
beta  C -0.3
beta  D 0.4
.......

and so on. 


I will add another variable afterwards:
var1  var2 corr   var3
alfa  A  1    grp1
alfa  B  0.3  grp1
alfa  C  0.8  grp2
alfa  D  -0.3 grp3
beta  A 0.2   grp3
beta  B 1     grp2
beta  C -0.3  grp1
beta  D 0.4   grp2
........ and so on....


I am sure there should be a way.. but I am completely
clueless.. 
Can any one help me please. 

thanks
srini




More information about the R-help mailing list