Please can you help to solve this issue:
round(30.5)
[1] 30
round(31.5)
[1] 32
I want to get always 0.5s either up or down. Any solution
Please can you help to solve this issue:
round(30.5)
[1] 30
round(31.5)
[1] 32
I want to get always 0.5s either up or down. Any solution
This is yet another instance of R-FAQ 7.31 (link to the FAQ on your device) ...... (link to the CRAN version). If you always want floating point numbers that are displayed by
print.default
as x.5 to "round up" then you need to add a bit of "fuzz". I chose that amount of fuzz to be similar to the accuracy with which print.default usually displays numbers.To make this happen in a function:
You might also ponder this:
A solution that does not need a print-format dependent offset:
To always round up, use
To always round down, use