View source: R/other_functions.R
roundup | R Documentation |
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.
roundup(x, digits = 0)
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. |
The rounded data vector.
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.