internalRoundFixedSum: Round values to whole numbers while preserving the sum

Description Usage Arguments Value References See Also Examples

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

1

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

See Also

Other data functions: internalSubAsRest

Examples

1
2
3
library(nbc4va)
dec <- c(rep(50/2, 2), rep(50/3, 3))
whole <- nbc4va:::internalRoundFixedSum(dec)

nbc4va documentation built on May 2, 2019, 1:42 p.m.