Open MichaelChirico opened 4 years ago
yes, that behaviour is wrong .... even though not encountered much in practice.
I will fix this for R-devel (and R-patched), so this fix will be in the next release of R... almost surely not in 2015 anymore, as today R 3.2.3 has been released.
AFAICS, the k-means method should with a single center (and I am able to run the following command):
(Using Iris dataset as an example)
K-means clustering with 1 clusters of sizes 150
Cluster means: Sepal.Length Sepal.Width Petal.Length Petal.Width 1 5.843333 3.057333 3.758 1.199333
Clustering vector: [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [66] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [131] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Within cluster sum of squares by cluster: [1] 681.3706 (between_SS / total_SS = 0.0 %)
... However, when a single center is provided instead, kmeans fails with an error. Verified using the centers generated by above command.
Error: number of cluster centres must lie between 1 and nrow(x)
The same error is not seen for nrows(centers) > 1.
METADATA