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
| Parameter | Type | Description |
|---|---|---|
| column | string | name of the column to bin |
| min | number | (Optional) inclusive minimum of the bin range |
| max | number | (Optional) inclusive maximum of the bin range |
| step | number | (Optional) the width each bin should be |
| clamped | boolean | (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. |
| format | boolean | (Optional) whether to return a formatted string that prints the bin range. |
Returns:
string | object