I'd like to change the way plot.hclust displays an hclust object. Here's a description of how it's done now, from the R documentation of hclust: In hierarchical cluster displays, a decision is needed at each merge to specify which subtree should go on the left and which on the right. Since, for n observations there are n-1 merges, there are 2^{(n-1)} possible orderings for the leaves in a cluster tree, or dendrogram. The algorithm used in hclust is to order the subtree so that the tighter cluster is on the left (the last, i.e. most recent, merge of the left subtree is at a lower value than the last merge of the right subtree). Single observations are the tightest clusters possible, and merges involving two observations place them in order by their observation sequence number. I have a factor vector (if that's the right term) for the observations, and I'd like to order the display of the leaves so that leaves of the same level are grouped together as much as possible. Even something as simple as putting the higher average code on the left would help. I've spent some time looking at the code in rpart, but I'm having a hard time figuring out what I need to modify. Or maybe someone's already done something similar? Any help much appreciated! David Marimont NXP Data Analysis, Inc. http://www.nxpdata.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
White.Denis@epamail.epa.gov
2002-Jan-14 00:25 UTC
[R] changing the ordering of leaves in a dendrogram
> I'd like to change the way plot.hclust displays an hclust object.Here's> a description of how it's done now, from the R documentation ofhclust:> > In hierarchical cluster displays, a decision is needed at eachmerge> to specify which subtree should go on the left and which on theright.> Since, for n observations there are n-1 merges, there are2^{(n-1)}> possible orderings for the leaves in a cluster tree, ordendrogram.> The algorithm used in hclust is to order the subtree so that the > tighter cluster is on the left (the last, i.e. most recent, merge > of the left subtree is at a lower value than the last merge ofthe> right subtree). Single observations are the tightest clusterspossible,> and merges involving two observations place them in order bytheir> observation sequence number. > > I have a factor vector (if that's the right term) for theobservations, and> I'd like to order the display of the leaves so that leaves of the same > level are grouped together as much as possible. Even something assimple> as putting the higher average code on the left would help. > > I've spent some time looking at the code in rpart, but I'm having ahard> time figuring out what I need to modify. Or maybe someone's alreadydone> something similar? Any help much appreciated! > > David Marimont > NXP Data Analysis, Inc. > http://www.nxpdata.comYou could look at function group.clust in contributed package maptree for possible ideas. Denis White US EPA, 200 SW 35th St, Corvallis, Oregon, 97333 USA voice: 541.754.4476, email: white.denis at epa.gov web: www.epa.gov/wed/pages/staff/white/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._