Learn R Programming

scidb (version 1.2-0)

kmeans: kmeans

Description

Basic kmeans clustering using Lloyd's algorithm

Usage

"kmeans"(x, centers, iter.max=30, nstart=1, algorithm="Lloyd")

Arguments

x
A scidb object representing a matrix.
centers
the number of clusters
iter.max
the maximum number of iterations allowed
nstart
Not (yet) used by this implementation
algorithm
Not (yet) used by this implementation (always Lloyd's)

Value

A list of class kmeans.

See Also

kmeans

Examples

Run this code
## Not run: 
# # Let's generate data with obvious clusters.
# set.seed(1)
# x <- c(x=rnorm(50),rnorm(50)+3);y = c(rnorm(50),rnorm(50)+3)
# A <- cbind(x,y)
# # Plot the data (try to set the aspect ratio square)
# # Let a be an m x n matrix.
# # Each row of the matrix A is a point in an n-dimensional Euclidean space.
# library("scidb")
# scidbconnect()
# A = as.scidb(A)
# k = kmeans(A, 2, 10)
# plot(A[], asp=1,xlab="x",ylab="y")
# points(A[k$cluster %==%0, ][], pch=19,col=4)
# ## End(Not run)

Run the code above in your browser using DataLab