I use the following R code to generate a dendrogram (see attached picture) with labels based on TraMineR sequences:
library(TraMineR)
library(cluster)
clusterward <- agnes(twitter.om, diss = TRUE, method = "ward")
plot(clusterward, which.plots = 2, labels=colnames(twitter_sequences))
The full code (including dataset) can be found here.
As informative as the dendrogram is graphically, it would be handy to get the same information in text and/or table format. If I call any of the aspects of the object clusterward (created by agnes), such as “order” or “merge” I get everything labeled using numbers rather than the names I get from colnames(twitter_sequences). Also, I don’t see how I can output the groupings represented graphically in the dendrogram.
To summarize: How can I get the cluster output in text/table format with the labels properly displayed using R and ideally the traminer/cluster libraries?

The question concerns the
clusterpackage. The help page for theagnes.objectreturned byagnes(See http://stat.ethz.ch/R-manual/R-devel/library/cluster/html/agnes.object.html ) states that this object contains an
order.labcomponent “similar toorder, but containing observation labels instead of observation numbers. This component is only available if the original observations were labelled.”The dissimilarity matrix (
twitter.omin your case) produced by TraMineR does currently not retain the sequence labels as row and column names. To get theorder.labcomponent you have to manually assign sequence labels as both therownamesandcolnamesof yourtwitter.ommatrix. I illustrate here with themvaddata provided by the TraMineR package.That is for getting
orderwith sequence labels rather than numbers. But now it is not clear to me which cluster outcome you want in text/table form. From the dendrogram you decide of where you want to cut it, i.e., the number of groups you want and cut the dendrogram withcutree, e.g.cl.4 <- cutree(clusterward1, k = 4). The resultcl.4is a vector with the cluster membership for each sequence and you get the list of the members of group 1, for example, withrownames(mvad.seq)[cl.4==1].Alternatively, you can use the
identifymethod (see?identify.hclust) to select the groups interactively from the plot, but need to pass the argument asas.hclust(cward). Here is the code for the exampleHope this helps.