round2 {rPraat} | R Documentation |
round2
Description
Rounds a number to the specified order. Round half away from zero (this is the difference from built-in round
function.)
Usage
round2(x, order = 0)
Arguments
x |
number to be rounded |
order |
0 (default) = units, -1 = 0.1, +1 = 10 |
Value
rounded number to the specified order
See Also
Examples
round2(23.5) # = 24, compare: round(23.5) = 24
round2(23.4) # = 23
round2(24.5) # = 25, compare: round(24.5) = 24
round2(-23.5) # = -24, compare: round(-23.5) = -24
round2(-23.4) # = -23
round2(-24.5) # = -25, compare: round(-24.5) = -24
round2(123.456, -1) # 123.5
round2(123.456, -2) # 123.46
round2(123.456, 1) # 120
round2(123.456, 2) # 100
round2(123.456, 3) # 0
round2(-123.456, -1) # -123.5
round2(-123.456, -2) # -123.46
round2(-123.456, 1) # -120
round2(-123.456, 2) # -100
round2(-123.456, 3) # 0
[Package rPraat version 1.3.2-1 Index]