`doKmeans()` performs k-means clustering on a data matrix `X` and returns both the full `kmeans` object along with the resulting cluster labels.

This function standardizes how PART calls k-means and ensures consistent use of the `nstart` parameter. K-means in this context always uses Euclidean distance.

doKmeans(X, k, nstart)

Arguments

X

A numeric data matrix where rows represent observations and columns represent features.

k

The number of clusters to form. Must be at least 1 and strictly less than the number of observations.

nstart

The number of random initializations used in the k-means algorithm. Passed directly to `stats::kmeans()` to improve robustness of results.