arrondi {SPARTAAS} | R Documentation |
Returns the rounded value.
Description
Always returns the upper value if the next digit is 5.
Usage
arrondi(x, acc)
Arguments
x |
The number to round. |
acc |
Accuracy (number of digits). A negative number of digits means rounding to the power of ten, e.g. arrondi(x, digits = -2) will round to the nearest hundred. |
Value
res |
Value or vector of values rounded. |
Author(s)
A. COULON
L. BELLANGER
P. HUSI
Examples
library(SPARTAAS)
x1 <- c(15,25,35,45,55)
round(x1,-1)
arrondi(x1,-1)
x2 <- c(-15,-25,-35,-45,-55)
round(x2,-1)
arrondi(x2, -1)
x3 <- 1.125
round(x3,2)
arrondi(x3, 2)
x4 <- seq(-0.55,0.55,0.1)
data.frame(
val = x4,
round = round(x4,1),
arrondi = arrondi(x4, 1),
equal = (arrondi(x4, 1) == round(x4,1))
)
[Package SPARTAAS version 1.2.4 Index]