is there a predefined format-function that rounds a number to the first 3 digits? (The start should be a numbers != 0)
-0.02528498 to -0.0253
1.857403 to 1.86
2060943 to 2060000
0.00006513832 to 0.0000651
You can use the function signif
:
signif(-0.02528498, 3)
# [1] -0.0253
signif(1.857403, 3)
# [1] 1.86
signif(2060943, 3)
# [1] 2060000
signif(0.00006513832, 3)
# [1] 0.0000651
base
package is full of wonders :-) . Even after 10 yrs I still find new tools in there.
Commented
Apr 16, 2015 at 12:35