0

Its a very basic question, unfortunately I do not know how to ask it. Lets say I have the following code for clustering using hclust:

hc <- hclust(dist(USArrests), "ave")
s = cutree(hc,k=2)

Lets assume sort(s) gives the following result:

Alabama Alaska Arizona Delaware Florida
   1     1       1        2       2

How can I get Alabama Alaska Arizona Delaware Florida in a list without the bottom cluster number getting appended to it.

4

1 回答 1

1

You can get the names from the vector itself (as mentioned by @AEBilgrau) names(sort(s)). Also, in this particular case, the cutree output will be in the order of the labels of the tree, so you could also use labels(hc).

于 2016-11-30T19:04:33.327 回答