Description Usage Arguments Examples
Takes a vector of values that are meant to be added together and
rounds them in such a way that the sum of each of the rounded values equals
the rounded sum of the unrounded values. For example, c(1.2, 1.3,
1.4)
sums to 3.9, which becomes 4 when rounded to the nearest integer.
However, rounding each of the values to the nearest integer produces
c(1, 1, 1)
, which only sums to 3. This function will "hard round"
the 1.4 up to 2, so that the resulting vector c(1, 1, 2)
sums to 4.
This is a common practice in preparing financial statements.
1 | hard_round(x, units)
|
x |
A numeric vector of values to be rounded. |
units |
A number indicating the units to which to round. Unlike R's
|
1 | hard_round(x = c(1.2, 1.3, 1.4), units = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.