Reputation: 71
I am using hclust
function to cluster a text based field in a data frame. For this I had to do some text cleaning and thus I extracted the text data to use tm_map
function for the same. After that I applied a clustering algorithm.
The clustering is working fine but I don't know how to associate the original data frame with the clusters created.
I am new to R and searched for any available solutions online but couldn't find any. Is it possible to do what I am trying?
Upvotes: 0
Views: 1834
Reputation: 607
Just had the same question. Here is what I did. Not sure if its correct but seems to work
1) from your hclust object, create a new object with just the ordered column
hh1 = hclust(dist(dataMatrix))
DataMatrixOrdered= data.frame(hh1$order)
2) Combine Ordered data frame and original data
DataMatrixOrderedCbind = cbind(dataMatrix, DataMatrixOrdered[,1])
Upvotes: 3