break.ward {mining}R Documentation

Quantize by clustering

Description

Quantize a one-dimensional variable by calling a clustering routine.

Usage

break.ward(x,n=2,plot=T)
break.hclust(x,n=2,method="ward",plot=T)
break.kmeans(x,n=2,plot=T)

Arguments

x a numerical vector
n the desired number of bins
method argument given to hclust
plot If TRUE, a histogram with break lines is plotted (hist.hclust or plot.breaks). For break.ward and break.hclust, also shows a merging trace (plot.hclust.trace).

Details

These are convenience routines which simply call the appropriate clustering routine (ward, hclust, or kmeans), convert the output to a break vector, and make plots.

Value

A break vector, suitable for use in cut or hist.

Author(s)

Tom Minka

Examples

x <- c(rnorm(700,-2,1.5),rnorm(300,3,0.5))
break.ward(x,2)
break.hclust(x,2,method="complete")
break.kmeans(x,2)

x <- c(rnorm(700,-2,0.5),rnorm(1000,2.5,1.5),rnorm(500,7,0.1))
break.ward(x,3)
break.hclust(x,3,method="complete")
break.kmeans(x,3)

[Package Contents]