Labelling a hclust dendogram using multiple factors

58 Views Asked by At

I am doing some hierarchical cluster analyses of some ecological data & I am struggling w/the labels, which are numeric and all but meaningless: dendogram w/meaningless labels

Essentially I would like to bind together the two factorial columns in my data to create labels that clarify which data points are what, and I do not understand R's labelling system well enough to understand what I am trying to do.

If seeing my code will help you understand better, then here it is:

nta ##data frame: 32obs, 40 variables - 
    ##$Quadrant factor w/8levels
    ##$Position factor w/4levels
nta.bc ##bray-curtis dissimilarity matrix of data
nta.hclust ##average-linked cluster object of nta.bc

##attempt to plot w/labels
plot(nta.hclust) +
  labels(nta, which = c(nta$Quadrant,nta$Position)) +
  rect.hclust(nta.hclust,k=4)

does anyone have any pointers?

1

There are 1 best solutions below

2
dcarlson On

You should include sample data using dput() so that we can illustrate the answer with a sample of your own data. Also provide actual code not comments since the problem may lie in your code. Here is an example using the varespec data that is included in package vegan. The main problem is that you are using ggplot2 syntax with base graphics functions. Did you get error messages that you did not include in your question?

data(varespec)    # Load varspec data set included in vegan
vsp.bc <- vegdist(varespec, method="bray")
vsp.hcl <- hclust(vsp.bc, method="average")
plot(vsp.hcl, labels=paste("Plot", rownames(varespec)))
rect.hclust(vsp.hcl, k=4)

Dendrogram