assign.optbin | R Documentation |
assign.optbin
returns an object with the same shape as the input
data and values replaced by bin numbers.
assign.optbin(x, binspec, extend.upper=FALSE, by.value=FALSE)
x |
numeric data to assign |
binspec |
an optimal binning partition |
extend.upper |
if true then any value in x above the last bin is assigned to that bin, otherwise its bin is set to NA |
by.value |
if true then return average value for bin instead of bin numbers |
Replaces the values in a copy of the input data by the bin number it belongs to, or by the bin average value with by.value. The lowest bin always extends to -Inf. The extend.upper argument can open the last bin to +Inf if true. Use this function to get in-place bin assignments for the unsorted data that was passed to optbin.
An object of the same shape as the data.
optbin
d <- c(rnorm(30, mean=10, sd=2), rnorm(40, mean=20, sd=2),
rnorm(30, mean=30, sd=3))
binned <- optbin(d, 3)
assign.optbin(d, binned)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.