tables.fixedbinstep.md

January 18, 2023 ยท View on GitHub

Home > @datashaper/tables > fixedBinStep

fixedBinStep() function

Bins column values using a fixed bin width. The number of resulting bins is therefore variable. The standard behavior here is to truncate a numeric value to the lower bound of its bin range. This keeps the output numerical but loses information about specific bin boundaries. Because binning is a conversion from continuous to categorical, many use cases prefer an output value that displays the range. The format parameter here will produce a printed string as output.

Signature:

export declare function fixedBinStep(column: string, min?: number, max?: number, step?: number, clamped?: boolean, format?: boolean): string | object;

Parameters

ParameterTypeDescription
columnstringname of the column to bin
minnumber(Optional) inclusive minimum of the bin range
maxnumber(Optional) inclusive maximum of the bin range
stepnumber(Optional) the width each bin should be
clampedboolean(Optional) whether values outside of the bin range should be clamped to the bounds. If this is false, out-of-bounds values will be +/-Infinity.
formatboolean(Optional) whether to return a formatted string that prints the bin range.

Returns:

string | object