I need a R function that always returns same number of digits after the decimal point regardless of how big the argument is. I tried round() but it does not work this way. Here is my example:
Rweb:> round(111234.678912,4) # expect 111234.6789
[1] 111234.7
Rweb:> round(111234.678912/10,4) # expect 11123.4679
[1] 11123.47
Rweb:> round(111234.678912/100,4) # expect 1112.3468
[1] 1112.347
Rweb:> round(111234.678912/1000,4)
[1] 111.2347
Rweb:> round(111234.678912/10000,4)
[1] 11.1235
It does work if the argument is in exponential format but I need work with numbers in floating format.