kmeans | R Documentation |
k-means algorithm in clustering. This function export the clustered results based on one replication of the k-means method
kmeans(x, centers, nItter = 4)
x |
matrix of data (dim 1: samples (must be equal to dim 1 of X), dim 2: attributes (must be equal to dim 2 of X)) |
centers |
initial seleted centroids (randomly or another method) |
nItter |
Number of itteration function |
clustered results based on k-means methods.
{
X=rbind(matrix(rnorm(1000*2 ,4,.1),1000,2),matrix(rnorm(1000*2, 3, 0.2),1000,2))
M <- X[sample(nrow(X), 2),]
kmeans(X,M, 4)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.