[R] Writing as matrix

Srinivas Iyyer srini_iyyer_bio at yahoo.com
Mon Feb 28 00:02:12 CET 2005


Dear Group, I am calculating correlation coeff.
between two populations. After calculating the
cor.coefs I want to represent them as a matrix file. 

   a   b   c   d
A  1   0   1   1
B  1   1   1   1 
C  1   0   1   0
D  0   1   1   1 


could any one please help me how can i acheive this:

> dim(e1)
[1] 22283    60
> dim(e2)
[1] 22283   158
> sink("old_new.txt")
>round(cor(cbind(e1,e2),use="complete.obs"))
>sink()

Currently this is the way my result looksL
            a
A           1
B           1
C           1
D           0
            b
A           0
B           1
C           0
D           1




I want to see my result as:
   a   b   c   d
A  1   0   1   1
B  1   1   1   1 
C  1   0   1   0
D  0   1   1   1 


thankyou 
srini




More information about the R-help mailing list