ps_round_preserve_sum: Round Values while Preserving their Rounded Sum

View source: R/round-preserve-sum.R

ps_round_preserve_sumR Documentation

Round Values while Preserving their Rounded Sum

Description

Round Values while Preserving their Rounded Sum

Usage

ps_round_preserve_sum(x, digits = 0L)

Arguments

x

A numeric vector of values to round

digits

A count of the number of decimals for rounding

Source

http://biostatmatt.com/archives/2902

Examples

sum(c(0.33, 0.33, 0.33))
round(c(0.33, 0.33, 0.33), 1)
sum(round(c(0.33, 0.33, 0.33), 1))
ps_round_preserve_sum(c(0.33, 0.33, 0.33), 1)
sum(ps_round_preserve_sum(c(0.33, 0.33, 0.33), 1))

poissonconsulting/poisutils documentation built on Feb. 26, 2023, 10 a.m.