I want to round my data with significant digits. Therefore I am using signif
to achieve that.
For example:
signif(0.0054324, digits=2)
[1] 0.0054
However, I realised that there are some cases where signif
doesn't work as I expected.
signif(1003.04, digits=3)
[1] 1000
signif(1005.04, digits=3)
[1] 1010
As you can see, in the previous examples, it seems that it is using ceiling
or just giving me integers, without any digits.
Note that I don't want to work with round
because I have some cases like this (see example below) and I don't want 0s.
round(0.000000054324, digits=2)
[1] 0
For that case, signif
gives me exactly what I want.
signif(0.000000054324, digits=2)
[1] 5.4e-08
Does anyone have any idea about how can I fix that when I use "big" numbers? (Since it works perfectly with small ones). Or if you know any other method.
Thanks very much in advance