Learn R Programming

Ckmeans.1d.dp (version 3.4.0-1)

print.Ckmeans.1d.dp: Print Results from Ckmeans.1d.dp

Description

Print the result returned from Ckmeans.1d.dp

Usage

## S3 method for class 'Ckmeans.1d.dp':
print(x, \dots)

Arguments

x
object returned by calling Ckmeans.1d.dp
...
Ignored arguments

Value

  • An object of class "code{Ckmeans.1d.dp}" which has a print method and is a list with components:
  • clustera vector of integers (1:k) indicating the cluster to which each point is allocated.
  • centersa numeric vector of cluster means.
  • withinssa numeric vector of within-cluster sums of squares for each cluster.
  • sizea vector of the number of points in each cluster.
  • totsstotal sum of squares of the input numbers.
  • tot.withinsstotal sum of within-cluster distance squares.
  • betweenssbetween-cluster sum of squares, equal to the sum of squared cluster means weighed by cluster size.

Details

The maximum ratio of between-cluster sum of squares to total sum of squares is printed unless all input numbers are zero. The ratio is an indicator of clustering quality: 100% for perfect clustering and 0% for worst clustering.

References

Wang, H. and Song, M. (2011) Ckmeans.1d.dp: optimal k-means clustering in one dimension by dynamic programming. The R Journal 3(2), 29--33. Retrieved from http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Wang+Song.pdf

Examples

Run this code
# Example: clustering data generated from a Gaussian mixture model of two components
x <- rnorm(50, mean=-1, sd=0.3)
x <- append(x, rnorm(50, mean=1, sd=0.3) )
res <- Ckmeans.1d.dp(x)
print(res)

Run the code above in your browser using DataLab