Ffenics
2006-Aug-16 12:46 UTC
[R] advice on exporting a distance matrix in the correct format needed please
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]]
Hans-Joerg Bibiko
2006-Aug-16 13:10 UTC
[R] advice on exporting a distance matrix in the correct format needed please
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. > >