round_trunc | R Documentation |
In normal R rounding, if the first digit to be dropped is exactly 5, R uses the standard programming convention of rounding to the nearest even number. This can have some annoying effects.
This function rounds numbers to the nearest integer, but always rounds to the integer with the highest absolute value when the first digit to be dropped is exactly 5, similar to rounding in usual mathematical contexts.
round_trunc(x, digits = 0)
x |
A number. |
digits |
Number of digits to round to. Default is 0 |
An integer.
# If the first digit to be dropped is exactly 5, round_trunc() will round to
# integer with the highest absolute value.
round_trunc(0.5)
round_trunc(-0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.