[R] Matrix to "indexed" vector
    Sean Davis 
    sdavis2 at mail.nih.gov
       
    Tue Jan 11 13:35:40 CET 2005
    
    
  
I have a matrix that I want to turn into a transformed matrix that 
includes the indices from the original matrix and the value.  The 
matrix is simply real-valued and is square (and large (8k x 8k)).  I 
want something that looks like (for the 3x3 case):
i	j	value
1	1	1.0
1	2	0.783432
1	3	-0.123482
2	1	0.783432
2	2	1.0
2	3	0.928374
and so on....
I can do this with for loops, but there is likely to be a better way 
and for my own edification, I would like to see what others would do.  
I am sinking the results to a file for loading into SQL database.
Thanks,
Sean
    
    
More information about the R-help
mailing list