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.

motiur
  • 1,640
  • 9
  • 33
  • 61

1 Answers1

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).

Tal Galili
  • 24,605
  • 44
  • 129
  • 187