Rounds a numeric vector so that the individual rounded values sum exactly to a target total. Uses the largest-remainder method (Hamilton method).
Examples
round_to_sum(c(3.3, 3.3, 3.4), target = 10)
#> [1] 3 3 4
Rounds a numeric vector so that the individual rounded values sum exactly to a target total. Uses the largest-remainder method (Hamilton method).
round_to_sum(c(3.3, 3.3, 3.4), target = 10)
#> [1] 3 3 4