>From: Madeleine Seeland <madeleine.seeland <at> in.tum.de> >Subject: help with hclust >Date: 2011-09-14 08:14:48 GMT >Hello, > >I have two questions regarding hclust: > >1) First I would like to cut a hclust tree at a specific height and receive the cluster (di) similarity at this >height.
With an example: hc <- hclust(dist(USArrests), "ave") plot(hc, hang = -1) hc.cf <- cophenetic(hc) #cophenetic distance # cut cluster at height=50 rect.hclust(hc, h = 50) hc.50 <- cutree(hc, h=50) hc.simi <- NULL for(i in unique(hc.50)) hc.simi <- c(hc.simi, max(as.matrix(hc.cf)[names(hc.50[hc.50==i]),names(hc.50[hc.50==i])])) hc.simi [1] 44.28392 44.83793 20.59851 38.52791 41.09477 >2) Next, I would like to receive all clusterings up to a given tree height that fulfill a minimal required >similarity (i.e., the inner cluster similarity of all clusters needs to fulfill a given similarity >value). How can I achieve that? For example, all clusterings with a (di)similarity at least 40 # which clusters have a maximum dissimilarity < 40 hc.le.40 <-unique(hc.50)[hc.simi<40] # clusterings up to a height of 40 hc.50[hc.50==hc.le.40[1]|hc.50==hc.le.40[2]] Connecticut Florida Idaho Indiana Kansas 3 4 3 3 3 Kentucky Montana Nebraska North Carolina Ohio 3 3 3 4 3 Pennsylvania Utah 3 3 HTH, MArcelino > >I would appreciate your help! > >Best regards, >Madeleine > ____________________________________ Marcelino de la Cruz Rot Depto. Biologia Vegetal EUIT Agricola Universidad Politecnica de Madrid tel: 34 + 913365435 ____________________________________ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.