powered by
Rounds a vector of numbers while preserving the sum of them.
round_preserve_sum(x, digits = 0)
round_preserve_sum returns y with round vector.
round_preserve_sum
y
A numeric vector.
The number of digits to take in account in the rounding process.
sum(c(0.333, 0.333, 0.334)) round(c(0.333, 0.333, 0.334), 2) sum(round(c(0.333, 0.333, 0.334), 2)) round_preserve_sum(c(0.333, 0.333, 0.334), 2) sum(round_preserve_sum(c(0.333, 0.333, 0.334), 2))
Run the code above in your browser using DataLab