break_ward: Quantize by clustering

View source: R/mining.R

break_wardR Documentation

Quantize by clustering

Description

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

Usage

break_ward(x, n = 2, plot = T)

Arguments

x

a numerical vector

n

the desired number of bins

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).

method

argument given to hclust

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)


paulemms/datamining documentation built on March 1, 2023, 4:01 p.m.