Here round()
behaves as expected:
round(3.5)
[1] 4
However this was surprising to me:
round(2.5)
[1] 2
Question
In times when we want everything ending in .5
to be rounded up, what's best practice in R to achieve that?
Note
Ideally the solution should also cater for rounding beyond the first decimal place e.g. the following should return 0.2
:
round(0.15, 1)
[1] 0.1