merging two dendrograms at a specific node
I would like to either:

1) remove a subtree and then merge a new subtree to the original dendrogram so that it is in the same position as the one removed.
2)or replace a subtree with another one.

I know that merge() can merge two dendrograms at the top. Does it also merge it at a specified node. If so how? If not, is there another method that would do that?

I know that cut() cuts the dendrogram at a certain height or into a specific number of node. But how do I make it remove only a specific subtree?

The specification of a subtree would be the attribute of the first node in it. eg attr(n,"attribute")== something, which can be done through dendrapply.

Here's a sample code of how the dendrograms are made.
==

    library("stats")
    library("fastcluster")
    
    x=matrix(c(1:20),ncol=4)
    y=matrix(c(21:40),ncol=4)
    
    #creating hclusters
    xcl=hclust.vector(x)
    ycl=hclust.vector(y)
    
    #converting to dendrograms
    xdend=as.dendrogram(xcl)
    ydend=as.dendrogram(ycl)
    
    # merging two dendrograms at the top
    zdend=merge(xdend,ydend)

==

Thanks

merging two dendrograms at a specific node
===

I would like to either:

1) remove a subtree and then merge a new subtree to the original dendrogram so that it is in the same position as the one removed.
2)or replace a subtree with another one.

I know that merge() can merge two dendrograms at the top. Does it also merge it at a specified node. If so how? If not, is there another method that would do that?

I know that cut() cuts the dendrogram at a certain height or into a specific number of node. But how do I make it remove only a specific subtree?

The specification of a subtree would be the attribute of the first node in it. eg attr(n,"attribute")== something, which can be done through dendrapply.

Here's a sample code of how the dendrograms are made.
==

    library("stats")
    library("fastcluster")
    
    x=matrix(c(1:20),ncol=4)
    y=matrix(c(21:40),ncol=4)
    
    #creating hclusters
    xcl=hclust.vector(x)
    ycl=hclust.vector(y)
    
    #converting to dendrograms
    xdend=as.dendrogram(xcl)
    ydend=as.dendrogram(ycl)
    
    # merging two dendrograms at the top
    zdend=merge(xdend,ydend)

==

Thanks
