Learn R Programming

bda (version 1.2.7-31)

binning: Data prebinning

Description

To bin the data over an equally-spaced grid.

Usage

binning(x, weights, breaks, binned = FALSE,
       range.x, na.rm=TRUE)

Arguments

x
a numeric value or a vector.
weights
A vector of weights for the values of x
breaks
A single value of number of classes, or a string specifying the bin width selector, or a vector giving the breakpoints between the bins.
binned
Have the data been binned. Default: FALSE.
range.x
The range of x
na.rm
logical; if TRUE, missing values are removed from x and weights. If FALSE any missing values cause an error.

See Also

hist.

Examples

Run this code
ofc0 = rnorm(1000,34.5,1.5)
 ofc = round(ofc0)
 out0 = binning(ofc0)
 out = binning(ofc, binned=TRUE)
 plot(out, type='l')
 lines(out0, col=2)

Run the code above in your browser using DataLab