bin.var

0th

Percentile

Bin a Numeric Varisible

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.

Keywords
manip
Usage
bin.var(x, bins = 4, method = c("intervals", "proportions", "natural"),
    labels = FALSE)
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.
Value

  • A factor.

See Also

cut, kmeans.

Aliases
  • bin.var
Examples
summary(bin.var(rnorm(100), method="prop", labels=letters[1:4]))
Documentation reproduced from package Rcmdr, version 1.1-2, License: GPL version 2 or newer

Community examples

Looks like there are no examples yet.