[R] accessing the "address" of items in a recursive list

Jesse D Lecy jdlecy at maxwell.syr.edu
Sun Nov 25 19:42:43 CET 2007

Dear useRs,

I am working on a project involving the clustering of a large dataset.  I need to extract specific sub-clusters from the parent dendrogram for further analysis.  The data is too large for the use of convenient tools such as identify.clust (it selects the specific group of interest on a graph), so alternatively I have saved the plot as a large image file so that it can be printed or viewed piecemeal.  My problem is this: when I find the subclusters that I need to analyze I have no way to reference that specific component of the dendrogram in order to extract it:

smallDend <- dend[[i]][[j]][[k]]  where i,j,k refer to levels of the dendrogram (it's "address")

I would like to print the "address" of the smaller dendrograms on the edge similar to this:

addr <- function(n) {
      if(!is.leaf(n)) {
        attr(n, "edgetext") <- paste("height of",(attr(n,"height"))
labeledDends <- dendrapply(dend, addr)

Where "i,j,k" is printed instead of "height".  But I have not been able to figure out how to ask each dendrogram its address within the dendrapply function.  Can anyone help me with this?

Many thanks,

PhD Student in Social Science
Syracuse University

More information about the R-help mailing list