exportinging dissimilarity results

4 views
Skip to first unread message

samlestrade

unread,
May 15, 2008, 4:13:14 AM5/15/08
to CorpLing with R
Hi all,
Does anyone know how we can export the results from a dissimilarity
analysis (e.g. agnes) to a csv/txt or whatever file? (We want to use
it as the input for the SplitsTree4 program).
Thanks!
Sander and Peter

Stefan Th. Gries

unread,
May 15, 2008, 6:39:54 AM5/15/08
to corplin...@googlegroups.com
Hi

What do you mean by "dissimilarity analysis (e.g. agnes)"? The
dissimilarity matrix returned by dist or Dist? If that's what you
mean, try this:

x<-matrix(rnorm(200), byrow=T, ncol=10) # generate random data
y<-dist(x, diag=T, upper=T) # generate a dissimilarity matrix
z<-apply(as.matrix(y), 1, paste, sep="\t")
write.table(z, file="temp.txt", sep="\t", quote=F, col.names=NA)

HTH,
STG
--
Stefan Th. Gries
-----------------------------------------------
University of California, Santa Barbara
http://www.linguistics.ucsb.edu/faculty/stgries
-----------------------------------------------

samlestrade

unread,
May 16, 2008, 9:18:33 AM5/16/08
to CorpLing with R
Dear Stefan,

Many thanks!
Your solution ("as.matrix()") worked to extract the dissimilarity
component ($diss) of the agnes (hierarchical clustering) function.
Now we can draw trees :)

Best,
Peter en Sander
Reply all
Reply to author
Forward
0 new messages