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
| Parameter | Type | Description |
|---|---|---|
| column | string | name of the column to bin |
| min | number | inclusive minimum of the bin range |
| max | number | inclusive maximum of the bin range |
| count | number | number of bins to create, they will be equal width |
| 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