I understand that the round function in R does not always round up with .5, that's why the following code:
x <- seq(0.5, 9.5, by=1)
#[1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5
round(x, 0)
results in 0, 2, 2, 4, 4..., instead of 1, 2, 3, 4, 5...
However, when I used the following numbers:
y <- seq(105.405, 105.505, .01)
#[1] 105.405 105.415 105.425 105.435 105.445 105.455 105.465 105.475 105.485 105.495 105.505
round(y, 2)
it showed the following results:
[1] 105.40 105.42 105.42 105.44 105.45 105.46 105.47 105.47 105.48 105.50 105.50
which it sometimes round to 5 or 7.
Does anyone know what the problem is and how to fix it? Is there any update or package that fixes the problem or do we have to write our own function?