I have been troubled by this simple question. I'd like to round numbers that has the last digit in 5 (like 0.45, or 0.85) to the format of 1 digit. When I used the round()
function in R on, for example 0.45
, it didn't round up to 0.5
, but down to 0.4
:
round(x = 0.45, digits = 1)
#> 0.4
I am aware that it may relate to the features of floating-point numbers and the "round half to even" rounding method of the round()
function. I am just wondering how can I get the 'correct' rounding in R?