« Return to Thread: Is there in R a function equivalent to the mround, as found in most spreadsheets?

Re: Is there in R a function equivalent to the mround, as found in most spreadsheets?

by Alberto Santini :: Rate this Message:

Reply to Author | View in Thread

Hello Luca.

Dr. Ottorino-Luca Pantani wrote:
...

c(1803.02, 193.51, 3.47)

Each solution is to be taken with 3 different pipettes (5000, 250 and 10
µL Volume max) and each of those delivers volumes in steps of 50 µL,  5
µL  or 1µL, respectively
Since the above values  would eventually become

c(1800, 195, 3)

...
You find a complete solution at
  http://albertosantini.blogspot.com/2008/05/mround.html

It checks the sign of the number and the multiple and it hacks the issue of rounding off a 5 respect IEC 60559 standard.

The test cases are:

mround(10, 3) # 9
mround(-10, -3) # -9
mround(1.3, 0.2) # 1.4
mround(5, -2) # error
mround(1.7, 0.2) # 1.8
mround(321.123, 0.12) # 321.12
mround(1803.02, 50) # 1800
mround(193.51, 5) # 195
mround(3.47, 1) # 3


Regards,
Alberto

 « Return to Thread: Is there in R a function equivalent to the mround, as found in most spreadsheets?