Hi all,
ok, i know i can cut a dendrogram, which i did. all i get is three objects that a dendrograms itself. for example: myd$upper, myd$lower[[1]], myd$lower[[2]] and so on. of course i can plot them seperately now. but the lower parts still have hundreds of branches. i´ll need a 30 " widescreen to watch the whole picture. what i´d like to is group the lower branches , so that i get a dendrogram with a few branches, splitting only in the upper levels. In terms of the cluster analysis, i just want to have a few bigger clusters. thx, m. P.S.: putting parts of a cutted dendrogram back into to one could be an idea ? is it somehow possible ? ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
On Fri, 2007-03-09 at 12:17 +0100, bunny , lautloscrew.com wrote:
> Hi all, > > ok, i know i can cut a dendrogram, which i did. > all i get is three objects that a dendrograms itself. > > for example: > myd$upper, myd$lower[[1]], myd$lower[[2]] > and so on. of course i can plot them seperately now. > > but the lower parts still have hundreds of branches. i´ll need a 30 " > widescreen to watch the whole picture. > what i´d like to is group the lower branches , so that i get a > dendrogram with a few branches, splitting only in the upper levels. > In terms of the cluster analysis, i just want to have a few bigger > clusters. > > thx, > > m. > > P.S.: > putting parts of a cutted dendrogram back into to one could be an > idea ? is it somehow possible ? Again, perhaps I'm missing something, but if I understand you correctly (again no example I can follow - what is myd and how did you create it?), you only want to plot the upper part of the dendrogram and not the lower branches. If so, then this /is/ on ?dendrogram and you /do/ use cut() to do it ...: 'cut.dendrogram()' returns a list with components '$upper' and '$lower', the first is a truncated version of the original tree, also of class 'dendrogram', the latter a list with the branches obtained from cutting the tree, each a 'dendrogram'. So to only show the pruned tree, you just plot $upper - it does say that $upper is a dendrogram and that it is the truncated version of the original tree - which is what I understand you to be asking for. This example shows it in action - this is what I mean by a reproducible example - (I'm using package vegan as I am familiar with this data set): require(vegan) ## if false install it data(varespec) hc <- hclust(vegdist(varespec, "bray"), method = "ward") hc <- as.dendrogram(hc) ## this is the full dendrogram - too many nodes, so prune plot(hc) ## lets take four clusters and prune it back hc.pruned <- cut(hc, h = 1) # can't specify k so read height of first # plot - cutting at h = 1 gives 4 clusters # plot only the upper part of the tree showing only the 4 clusters plot(hc.pruned$upper, center = TRUE) Is this what you want? If not, using the example I provide above, tell us exactly what you want to achieve. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
Though your example helped, i am still trying to get exactly what i
want. Here´s how i get my dendrogram. and my example... (using "ward" instead of average, doesnt make any difference for my case - i believe) hc=hclust(dist(mymatrix),"average") hcd=as.dendrogram(hc) plot(hcd) the major problem in my case is that my matrix has 196 lines, that means the end of the dendrogram has almost 200 end nodes. ofcourse i know "cut" meanwhile ;) ... but somehow the branches that i get by cut dont help me. If i look at the full dendrogram i have about 25 nodes. i just want to label about 5 of them (from the upper end). Everything that happens below is not of interest for me. Do you know how to label some specific nodes ? I´ll try max.levels... thx in advance m.- Am 09.03.2007 um 13:52 schrieb Gavin Simpson: > require(vegan) ## if false install it > data(varespec) > > hc <- hclust(vegdist(varespec, "bray"), method = "ward") > hc <- as.dendrogram(hc) > > ## this is the full dendrogram - too many nodes, so prune > plot(hc) > > ## lets take four clusters and prune it back > hc.pruned <- cut(hc, h = 1) # can't specify k so read height of first > # plot - cutting at h = 1 gives 4 clusters > > # plot only the upper part of the tree showing only the 4 clusters > plot(hc.pruned$upper, center = TRUE) [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
Free forum by Nabble | Edit this page |