internalRoundFixedSum: Round values to whole numbers while preserving the sum
Description
Rounds a vector of values to whole numbers while preserving the sum (rounded if it is not a whole number) using the largest remainder method (Gallagher, 1991).
Usage
internalRoundFixedSum(v, roundSum = round)
Arguments
v
A vector of values with decimal values and a whole number sum to round.
roundSum
If the sum of the values in v is not a whole number, choose a rounding method to ensure it is a whole number.
Value
out A vector of v with the values rounded to whole numbers but with the whole number sum preserved.
References
Gallagher M. Proportionality, disproportionality and electoral systems. Electoral Studies. 1991;10(1)33-51. doi:10.1016/0261-3794(91)90004-C.