Learn R Programming

AssocBin (version 1.1-0)

halfCutTie: Halve continuously to break ties

Description

This function halves a bin based on the midpoint of the bounds along whichever margin produces the larger score.

Usage

halfCutTie(bin, xscore, yscore, wider, squarify = FALSE)

Value

A list of two bins resulting from the split of `bin` in half along the margin corresponding to the larger score.

Arguments

bin

a bin to be split with elements `x`, `y`, `depth`, `bnds` (list with elements `x` and `y`), `expn`, `n`

xscore

numeric value giving the score for all splits along x

yscore

numeric value giving the score for all splits along y

wider

logical; is the bin wider than it is tall?

squarify

logical value, should we force splitting on the longer side regardless of scores?

Author

Chris Salahub

Details

The goal of this function is to break ties within bin splitting in a way which prevents very small or lopsided bins from forming, a common problem with the `halfSplit` function

Examples

Run this code
bin <- makeBin(x = 1:10, y = sample(1:10))
halfCutTie(bin, 1, 2, wider = FALSE) # splits on y
halfCutTie(bin, 2, 1, wider = FALSE) # splits on x
halfCutTie(bin, 1, 1, wider = FALSE) # ties are random

Run the code above in your browser using DataLab