Search code examples
rcluster-analysisk-means

Export kmeans clustering results to .csv


I've done a k-means clustering on my data, imported from .csv. Is there anyway to export the clustered results back to .csv file? Cos after the k-means clustering is done, the class of the variable is not a data frame but kmeans.


Solution

  • In most R package help files there will be a subheading that says "value" that describes the output from the analyses conducted. I have not used kmeans recently, but I believe you want something like this:

    kmeansresults<-kmeans(dataframe)
    x<-kmeansresults$clusters
    write.csv(x, file="name_of_file.csv")