roundup {common} | R Documentation |
Rounds numbers up
Description
A function that rounds positive numbers up when the last digit is a 5. For negative numbers ending in 5, the function actually rounds down. "Round away from zero" is the most accurate description of this function.
Usage
roundup(x, digits = 0)
Arguments
x |
A vector of values to round. Also accepts a data frame. In the case of a data frame, the function will round all numeric columns. |
digits |
A number of decimal places to round to. Default is zero. |
Value
The rounded data vector.
Examples
# Round to even
round(2.4) # 2
round(2.5) # 2
round(-2.5) # -2
round(2.6) # 3
# Round up
roundup(2.4) # 2
roundup(2.5) # 3
roundup(-2.5) # -3
roundup(2.6) # 3
[Package common version 1.1.3 Index]