Learn R Programming

AssocBin (version 1.1-0)

binner: Many split recursive binning

Description

`binner` is an iterative implementation of a recursive binary partitioning algorithm which accepts the splitting and stopping functions that guide partitioning as arguments.

Usage

binner(x, y, stopper, splitter, init = halfSplit, dropPoints = FALSE)

Value

A list of lists each with elements `x`, `y`, `bnds`, `expn`, `n`, and `stopped`.

Arguments

x

numeric vector of the first variable to be binned

y

numeric vector of the second variable to be binned

stopper

function which accepts a list with elements `x`, `y`, `bnds`, `expn`, and `n` and returns a logical indicating whether a split should occur for the bin defined by that list

splitter

function which accepts a list of lists with elements `x`, `y`, `bnds`, `expn`, and `n` and returns a list where each element is a list of two corresponding to a split of the bin at that position in the original list

init

function like `splitter` applied to the first bin

dropPoints

logical; should points be dropped from final bins?

Author

Chris Salahub

Details

`binner` creates a two-dimensional histogram of the sample space of `x` and `y` by recursively splitting partitions of the data using `splitter` until `stopper` indicates that all partitions are not to be split. An optional argument `init` gives the function applied to the first bin containing all points to initialize the binning algorithm.

Examples

Run this code
## necessary set up
crits <- makeCriteria(depth >= 4, n < 10, expn <= 5)
stopFn <- function(bns) stopper(bns, crits)
spltFn <- function(bn) maxScoreSplit(bn, chiScores)
## generate data
x <- sample(1:100)
y <- sample(1:100)
## run binner
bins <- binner(x, y, stopper = stopFn, splitter = spltFn)

Run the code above in your browser using DataLab