[R] advice on exporting a distance matrix in the correct format needed please

Hans-Joerg Bibiko bibiko at eva.mpg.de
Wed Aug 16 15:10:51 CEST 2006


In order to get a table structure out of a dist object use 'as.matrix 
()' like 'as.matrix(dist(myMatrix))' and write.table().

Hans

On 16 Aug 2006, at 14:46, Ffenics wrote:

> Hi there
> Could anyone please tell me how to export a distance matrix to  
> a .csv file please? when I tried write(matrix) I got the values but  
> not in the format of a distance matrix - just a list of numbers in  
> 4 columns - and when I try write.table(matrix, file="distance.csv")  
> I get the following
> Error in as.data.frame.default(x[[i]], optional = TRUE) :
>         cannot coerce class "dist" into a data.frame
> Any suggestions much appreciated
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list