tables.fixedbincount.md

January 18, 2023 ยท View on GitHub

Home > @datashaper/tables > fixedBinCount

fixedBinCount() function

Bins column values using a fixed number of bins. 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 fixedBinCount(column: string, min: number, max: number, count: number, clamped?: boolean, format?: boolean): string | object;

Parameters

ParameterTypeDescription
columnstringname of the column to bin
minnumberinclusive minimum of the bin range
maxnumberinclusive maximum of the bin range
countnumbernumber of bins to create, they will be equal width
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