GetBinNumber: Get bin number

Description Usage Arguments Details Value Author(s) Examples

View source: R/GraphAlignment.R

Description

Get the bin number for the argument using the specified lookup vector.

Usage

1
GetBinNumber(x, lookup, clamp=TRUE)

Arguments

x

value to be binned

lookup

lookup vector

clamp

clamp value to lookup range

Details

The lookup vector defines the lower and upper boundaries for each bin. The first entry in the lookup vector is the lower boundary of the first bin, while the last value in the lookup vector is the upper boundary of the last bin. For all other entries, entry i of the lookup vector defines the upper boundary of the (i-1)-th bin and the lower boundary of the i-th bin. The number of bins is therefore n-1, where n is the length of the lookup vector. A lookup vector must have at least two elements.

If clamping is enabled (clamp=TRUE), arguments which fall below the lower boundary of the first bin are treated as if they are actually in the first bin. Likewise, values which are above the upper boundary of the last bin are treated as if they are actually in the last bin. If clamping is disabled (clamp=FALSE), values outside the lookup range cause an error.

Value

This function returns the bin number corresponding to the input value. The bin number is obtained by performing a lookup in the specified lookup vector.

Author(s)

Joern P. Meier, Michal Kolar, Ville Mustonen, Michael Laessig, and Johannes Berg

Examples

1
2
3
  lookup <- c(-1, 0, 1)
  GetBinNumber(-0.5, lookup)
  GetBinNumber(0.5, lookup)

GraphAlignment documentation built on Nov. 8, 2020, 6:56 p.m.