k_means_cluster: K-Means Clustering

Description Usage Arguments Value Examples

View source: R/kmeans.R

Description

Algorithm for kmeans clustering of numeric matrix of data

Usage

1
k_means_cluster(x, k, tolerance = 1e-5, nstart = 9)

Arguments

x

A numeric matrix of data

k

A number of clusters; note that only when x>>k will k-means be robust.

tolerance

A tolerance number that determines whether the centroids are converge, default is 1e-5

nstart

An iteration number since k-means clustering depends on the initial centroids, default is 9

Value

The original data matrix x, a vector of the clusters, a matrix of the coordinates of k centroids

Examples

1
2
3
x = rbind(matrix(rnorm(100, sd = 0.3), ncol = 2), matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
k = 2
k_means_cluster(x, k)

silverfoxxxx/package1 documentation built on Nov. 25, 2019, 10:22 p.m.