Creates a tidy dataframe containing information at the cluster level for a kmeans clustering algorithm
tidy_kmeans(Model, X)
Model | A |
---|---|
X | data.frame of the original data set. |
tibble of infomration associated with each cluster
library(dplyr) library(sptidy) data(iris) data <- iris %>% select(-Species) kclust <- kmeans(data, centers = 3) tidy_kmeans(kclust, data)#> # A tibble: 3 x 3 #> cluster_number cluster_center n_points #> <int> <list> <int> #> 1 1 <dbl [3]> 33 #> 2 2 <dbl [3]> 21 #> 3 3 <dbl [3]> 96