[R] Fwd: cut.dendrogram and cutree

Agustin Lobo Agustin.Lobo at ija.csic.es
Mon Oct 29 08:34:25 CET 2007


But this is not solving my problem, let me further explain by following 
the example in the help page for dendrogram:

require(graphics); require(utils)
hc <- hclust(dist(USArrests), "ave")
dend1 <- as.dendrogram(hc)
dend2 <- cut(dend1, h=70)

What I want to know are the original elements in each of the final 
branches of dend2$upper (the ones labeled "Branch 1", "Branch 2" etc)
(or the branch for each of the original elements).

May be I could with dend2$lower, but can't find the way.


Yaomin Xu escribió:
> Sorry, forget to put your email address.
> ---------- Forwarded message ----------
> From: Yaomin Xu <yaomin at case.edu>
> Date: Oct 28, 2007 5:14 PM
> Subject: Re: [R] cut.dendrogram and cutree
> To: r-help at r-project.org
> Agus,
> we use cut.tree when it makes sense to use a specific h as a global
> criterion to split the tree.
> In your case, you might want to access the tree using '[['. Examples
> below borrow the samples you provided in your code:
> 1) There are two branches in your dend1. To get the left branch, you can do
>> dend1.1 <- dend1[[1]]
>> labels(dend1.1)
> where labels function gives you all the states you have under that branch.
> 2) There are two big sub-branches on the right branch of brand1, to
> access the right one of those two sub-branches, you can do,
> dend1.2.2 <- dend1[[c(2,2)]]  # or dend1.2.2<- dend1[[2]][[2]]
> lables(dend1.2.2)  ## will list you all the members.
> So the branches of a dendrogram object can be accessed in a binary
> tree fashion, use '1' for the tree on the left and '2' for the tree on
> the right.
> hope the above helps.
> yaomin
> ------
> Yaomin Xu
> Statstical Computing and Bioinformatics
> The Cleveland Clinic Foundation

Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es

More information about the R-help mailing list