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

Alberto Santini albertosantini at gmail.com
Sun May 11 11:42:40 CEST 2008


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


-- 
View this message in context: http://www.nabble.com/Is-there-in-R-a-function-equivalent-to-the-mround%2C-as-found-in-most-spreadsheets--tp17143519p17170296.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list