[R] matrix export

Eric Pante ericpante at hotmail.com
Thu Jan 19 20:05:27 CET 2006


Thanks, Bert

write.table won't do the trick, because distance matrices in R are 
presented as lower triangular matrices. write.table "cannot coerce 
class "dist" into a data.frame".

maybe there is a way to transform the lower triangular matrix into a 
full matrix, and then use write.table ?

cheers, Eric

On Jan 19, 2006, at 1:38 PM, Berton Gunter wrote:

> Just use write.table() from the base package with row.names=TRUE (the
> default).
>
> -- Bert Gunter
> Genentech Non-Clinical Statistics
> South San Francisco, CA
>
> "The business of the statistician is to catalyze the scientific 
> learning
> process."  - George E. P. Box
>
>
>
>> -----Original Message-----
>> From: r-help-bounces at stat.math.ethz.ch
>> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Eric Pante
>> Sent: Thursday, January 19, 2006 10:09 AM
>> To: r-help at stat.math.ethz.ch
>> Subject: [R] matrix export
>>
>> Dear listers,
>>
>> I need to export a distance matrix in the following format :
>>
>> a 0.0 1.0 0.2 1.0 1.0
>> b 1.0 0.0 1.0 1.0 1.0
>> c 0.2 1.0 0.0 1.0 1.0
>> d 1.0 1.0 1.0 0.0 1.0
>> e 1.0 1.0 1.0 1.0 0.0
>>
>> I tried write.matrix() from the MASS library, which gives:
>>
>> a b c d e
>> 0.0 1.0 0.2 1.0 1.0
>> 1.0 0.0 1.0 1.0 1.0
>> 0.2 1.0 0.0 1.0 1.0
>> 1.0 1.0 1.0 0.0 1.0
>> 1.0 1.0 1.0 1.0 0.0
>>
>> Does anyone know of an R trick to change the location of the headers
>> ?or do I need to do this externally, through perl or bash ?
>>
>> Thanks in advance for your help,
>> Eric
>>
>>
>> Eric Pante
>> ----------------------------------------------------------------
>> College of Charleston, Grice Marine Laboratory
>> 205 Fort Johnson Road, Charleston SC 29412
>> ----------------------------------------------------------------
>>
>> 	"On ne force pas la curiosite, on l'eveille ..."
>> 	Daniel Pennac
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>>
>
>
Eric Pante
----------------------------------------------------------------
College of Charleston, Grice Marine Laboratory
205 Fort Johnson Road, Charleston SC 29412
----------------------------------------------------------------

	"On ne force pas la curiosite, on l'eveille ..."
	Daniel Pennac




More information about the R-help mailing list