Learn R Programming

dbscan (version 1.2.1)

ncluster: Number of Clusters, Noise Points, and Observations

Description

Extract the number of clusters or the number of noise points for a clustering. This function works with any clustering result that contains a list element named cluster with a clustering vector. In addition, nobs (see stats::nobs()) is also available to retrieve the number of clustered points.

Usage

ncluster(object, ...)

nnoise(object, ...)

Value

returns the number if clusters or noise points.

Arguments

object

a clustering result object containing a cluster element.

...

additional arguments are unused.

See Also

Other clustering functions: dbscan(), extractFOSC(), hdbscan(), jpclust(), optics(), sNNclust()

Examples

Run this code
data(iris)
iris <- as.matrix(iris[, 1:4])

res <- dbscan(iris, eps = .7, minPts = 5)
res

ncluster(res)
nnoise(res)
nobs(res)

# the functions also work with kmeans and other clustering algorithms.
cl <- kmeans(iris, centers = 3)
ncluster(cl)
nnoise(cl)
nobs(res)

Run the code above in your browser using DataLab