GroupByTotal
GroupByTotal[values,target]⟹outGroups
groups values such that the total summation of a each grouping is as close to the target value as possible without going over.
GroupByTotal[{{label, value}..},target]⟹outGroups
groups based on values while perserving label information in the grouping.
Details
- GroupByTotal uses a greedy algorithm to successively construct each grouping to be individually closest to the target value and does not try to minimize the distance between all values together.
-
IncompatibleUnits The units for values `1` are incompatible with the units of the target value `2`. Please make sure to use values whose units are compatible with the target value's unit. IncompatibleValues The values `1` are greater then the target value `2`. Please make sure that all of the values to be grouped are equal to or less then the target value. UniqueLabels The labels `1` appear multiple times. Please provide a unique label for each of the values.
Input
Output
Messages
Examples
Basic Examples (3)
Additional Examples (5)
If multiple labels are used for a value, the grouping will be performed on the last entry of each value:
Zero values will be placed in the first available bin:
Only zero values will be placed in the first available bin:
Negative values will be placed in the first available bin:
GroupByTotal should be capable of grouping large datasets: