I wrote the follow code to clustering data :
clusrer.data <- function(data,n) {
  miRNA.exp.cluster <- scale(t(miRNA.exp))
  k.means.fit <- kmeans(miRNA.exp.cluster,n)
  #i try to save the results of k-means cluster by this code : 
  k.means.fit <- as.data.frame(k.means.fit)
  write.csv(k.means.fit, file="k-meanReslut.csv")
  #x<-k.means.fit$clusters
  #write.csv(x, file="k-meanReslut.csv")
}
but I can not save the clusters to outside of (clusters) (8, 6, 7, 20, 18), I want to save each cluster separated (with columns and rows) in txt file or CSV.
 
    