Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8388133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:24:11+00:00 2026-06-09T18:24:11+00:00

I use the following R code to generate a dendrogram (see attached picture) with

  • 0

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?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:24:12+00:00Added an answer on June 9, 2026 at 6:24 pm

    The question concerns the cluster package. The help page for the agnes.object returned by agnes
    (See http://stat.ethz.ch/R-manual/R-devel/library/cluster/html/agnes.object.html ) states that this object contains an order.lab component “similar to order, but containing observation labels instead of observation numbers. This component is only available if the original observations were labelled.”

    The dissimilarity matrix (twitter.om in your case) produced by TraMineR does currently not retain the sequence labels as row and column names. To get the order.lab component you have to manually assign sequence labels as both the rownames and colnames of your twitter.om matrix. I illustrate here with the mvad data provided by the TraMineR package.

    library(TraMineR)
    data(mvad)
    ## attaching row labels 
    rownames(mvad) <- paste("seq",rownames(mvad),sep="")
    mvad.seq <- seqdef(mvad[17:86]) 
    ## computing the dissimilarity matrix
    dist.om <- seqdist(mvad.seq, method = "OM", indel = 1, sm = "TRATE")
    ## assigning row and column labels 
    rownames(dist.om) <- rownames(mvad) 
    colnames(dist.om) <- rownames(mvad) 
    dist.om[1:6,1:6]
    
    ## Hierarchical cluster with agnes library(cluster) 
    cward <- agnes(dist.om, diss = TRUE, method = "ward")
    
    ## here we can see that cward has an order.lab component 
    attributes(cward)
    

    That is for getting order with 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 with cutree, e.g. cl.4 <- cutree(clusterward1, k = 4). The result cl.4 is a vector with the cluster membership for each sequence and you get the list of the members of group 1, for example, with rownames(mvad.seq)[cl.4==1].

    Alternatively, you can use the identify method (see ?identify.hclust) to select the groups interactively from the plot, but need to pass the argument as as.hclust(cward). Here is the code for the example

    ## plot the dendrogram
    plot(cward, which.plot = 2, labels=FALSE)
    
    ## and select the groups manually from the plot
    x <- identify(as.hclust(cward)) ## Terminate with second mouse button
    
    ## number of groups selected
    length(x)
    ## list of members of the first group
    x[[1]] 
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following code to generate a data table from datagridview Dim t1
I use the following code to generate a spam report using SpamAssassin: use Mail::SpamAssassin;
I normally use the following code to generate random colors: Random rand = new
I use svcutil to generate the following code: //------------------------------------------------------------------------------ // <auto-generated> // This code
I use the following PHP code to generate some JS and echo it in
I use the following code to generate a save file dialog: Response.AppendHeader(content-disposition, attachment; filename=
I use the following code to find hooks in the html, generate links from
I use following code: Create a retry policy, when error, retry after 1 second,
I just use following code to add an image to my project, var paper
I use VS2010, C# to develop Silverlight 4 app, I use following code in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.