I am reading about k-means clustering method.

How does the method calculate the mean between two coordination points? How does the method work with more than two dimensions? How can calculate the distance and the mean if there are more than two dimension?

Are there any packages about k-means clustering in R?

  • $\begingroup$ kmeans() is built into R, the function "gets loaded" with the set of libraries R always loads at startup, so you don't have to import or install anything. $\endgroup$
    – knb
    Jul 31, 2017 at 8:08

1 Answer 1


To answer simply, Euclidean distance is generally used:

$$ d = |\mathbf{x}-\mathbf{y}|=\sqrt{\sum_{i=1}^n|x_i-y_i|^2}$$

Read more about k-means over here:

Using kmeans() in R:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.