binbyvol {easyr}R Documentation

Bin by Volume

Description

Bins a numerical column according to another numerical column's volume. For example if I want to bin a column "Age" (of people) into 10 deciles according to "CountofPeople" then I will get Age breakpoints returned by my function such that there is 10 This function handles NA's as their own separate bin, and handles any special values you want to separate out. Author: Scott Sobel. Tech Review: Bryce Chamberlain.

Usage

binbyvol(df, groupby, vol, numbins)

Arguments

df

(Data Frame) Your data.

groupby

(Character) Name of the column you'll create cuts in. Must be the character name of a numeric column.

vol

(Character) Name of the column for which which each cut will have an equal percentage of volume.

numbins

Number of bins to use.

Value

Age breakpoints returned by my function such that there is 10

Examples

# bin Sepal.Width according to Sepal.Length.
iris$bin <- binbyvol(iris, 'Sepal.Width', 'Sepal.Length', 5)

# check the binning success.
aggregate( Sepal.Length ~ bin, data = iris, sum )

[Package easyr version 0.5-8 Index]