Learn R Programming

AssocBin (version 1.1-0)

halfSplit: Halve at an observed point

Description

This function halves a bin under the restriction that splits can only occur at observation coordinates.

Usage

halfSplit(bin, margin = sample(c("x", "y"), 1))

Value

A list of two bins resulting from the split of `bin` in half along the specified margin

Arguments

bin

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

margin

string, one of `x` or `y`

Author

Chris Salahub

Details

Given a bin and a margin, this function splits the bin so half the points are above the new split point and half are below.

Examples

Run this code
bin <- list(x = 1:10, y = sample(1:10),
            bnds = list(x = c(0, 10), y = c(0, 10)),
            expn = 10, n = 10, depth = 0)
halfSplit(bin)
halfSplit(bin, margin = "y")

Run the code above in your browser using DataLab