Dear Rajarshi,

I hope you are doing good.

Topwords.csv that was generated consists of the words and their frequency. We need one more column that represents the cluster that particular word belongs to.

E.g: 
sunday 148 1
cowboys 105 1
night 103 1
game 85 1
redskins 84 1
@dallascowboys 51 2
@redskins 36 2
@sportscenter 36 2
the 22 2
romo 12 2
.
.
.

To achieve you can use a simply for loop that goes through each cluster and finding the top 5 words for each cluster as shown below:

 topwords<-{}
 for( i in 1:10)
 {
 y<-Corpus(VectorSource(x$V1[x$V2==i] ))
 tdm <- TermDocumentMatrix(y)
 m<- as.matrix(tdm)
 v<- sort(rowSums(m), decreasing = TRUE)
 d<-cbind(v,i)
 words<-head(d,5)
 topwords<-rbind(topwords,words)
 }
  topwords

Try to generate the topwords.csv in this pattern and check.

Hope this helps you.

Please feel free to revert if you need any further help.

If you feel satisfied with my response kindly leave your feedback by clicking on any one of the below smileys
Please note if you are not happy with the response on this ticket, please escalate it to escalations@edureka.in.
We assure you that we will get back to you within 24 hours