[R] distance matrices

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Dec 3 19:17:38 CET 2009


On Thu, 2009-12-03 at 11:06 -0700, Omar Gonzalez Post wrote:
> i'm working on some distance matrices and i was wondering if there is
> a way to export the matrices from R to excel.
> OG
> thanks

If 'dij' is your dissimilarity matrix as a 'dist' object (special lower
triangular representation) then this will write it out for you: 

write.csv(as.matrix(dij), file = "foo.csv")

If 'dij' is a square matrix, then

write.csv(dij, file = "foo.csv")

will do it.

I haven't used Excel for a while, but when I did, it had a restriction
of 256 columns. If this restriction is still in place, the above file
won't fit into Excel if you have more than 255 samples.

HTH

G

>  		 	   		  
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list