Learn R Programming

extracat (version 1.7-6)

cutbw: Active binning

Description

Uses cut with breakpoints derived by getbw.

Usage

cutbw(x, k = NULL, min_n = NULL, warn = FALSE)

Arguments

x

A numeric variable.

k

The desired number of active bins. A bin is active if it contains at least min_n observations. The default is k <- 1 + 2*ceiling(log(N)/log(2)).

min_n

The minimum number of observations necessary for a bin to count as an active bin. Defaults to min_n = max(log(N/10)/log(10),1).

warn

Whether or not to print a warning if the desired number of bins is not possible.

Value

An ordinal factor variable.

See Also

getbw, ahist

Examples

Run this code
# NOT RUN {
y<-cutbw(c(rnorm(200),rnorm(100,mean=8)),k = 30, min_n = 1)
barplot(table(y))
# }

Run the code above in your browser using DataLab