[R] exporting clustering results to table

Martin Tomko martin.tomko at geo.uzh.ch
Tue Nov 27 13:41:23 CET 2007


Hello list,

the following approach did not work:

clustersA <- pam(distances, nkA, diss=TRUE);
gc();
filenameclu = paste("filenameclu", ".txt");
write.table(clustersA , file=filenameclu,sep=",");

although it worked with
clustersA <- hclust(distances, method="ward");
and a consecutive
kclassA <- cutree(clustersA, k=nkA);
filename = paste("clusters", ".txt");
write.table(kclassA,file=filename,sep=",",col.names=TRUE,row.names=TRUE);

Is there a <em>generic</em> method to export cluster object? I know that 
pam is different (cluster object and some more data)- how can I extract 
& export the clustering into a table with two columns, ID = 
dissimilarity matrix row, and cluster = number of the cluster?

I waas using sink to get the data, but for large matrices it involves a 
huge amount of manual formatting afterwards, let's say in excel.

Thanks many times
Martin



More information about the R-help mailing list