Reputation: 193
Is there a way to show the the member in a cluster after cutree step in R? for example:
tree <- hclust(dist, method='single')
plot(tree, hang=-1, cex=0.8)
cutree(tree, h=18)
I obtain sth like:
X10100 X3755 X13068 X264 X13216
1 1 2 2 3
X8379 X13727 X9925 X13849 X467
3 4 4 5 5
X14265 X388 X14426 X8246 X14961
6 6 7 7 8
X17037 X1200 X844 X13024 X155
8 9 9 10 11
I want to see/print it as a more straightforward way such as:
cluster 1: 10100,03755
cluster 2: ..........
How can I do it? Thanks!
Upvotes: 1
Views: 800
Reputation: 121568
You can group the results using split
or by
:
hh <- cutree(tree, h=18)
split(names(hh),hh)
Or
by(names(hh),hh,paste,collapse=',')
Upvotes: 1