Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bin.var

Bin a Numeric Varisible


Description

Create a factor dissecting the range of a numeric variable into bins of equal width, (roughly) equal frequency, or at "natural" cut points. The cut function is used to create the factor. bin.var is a synomym for binVariable, retained for backwards compatibility.

Usage

binVariable(x, bins = 4, method = c("intervals", "proportions", "natural"),
    labels = FALSE)
    
bin.var(...)

Arguments

x

numeric variable to be binned.

bins

number of bins.

method

one of "intervals" for equal-width bins; "proportions" for equal-count bins; "natural" for cut points between bins to be determined by a k-means clustering.

labels

if FALSE, numeric labels will be used for the factor levels; if NULL, the cut points are used to define labels; otherwise a character vector of level names.

...

arguments to be passed to binVariable.

Value

A factor.

Author(s)

Dan Putler, slightly modified by John Fox jfox@mcmaster.ca with the original author's permission.

See Also

Examples

summary(binVariable(rnorm(100), method="prop", labels=letters[1:4]))

RcmdrMisc

R Commander Miscellaneous Functions

v2.7-1
GPL (>= 2)
Authors
John Fox [aut, cre], Robert Muenchen [ctb], Dan Putler [ctb]
Initial release
2020-08-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.