Uses cut with breakpoints derived by getbw.

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.

Note

Experimental.

See also

Examples

y<-cutbw(c(rnorm(200),rnorm(100,mean=8)),k = 30, min_n = 1) barplot(table(y))