The general code in R for rounding a number is to say 2 decimal points:
> a = 14.1234 > round(a, digits=2) > a > 14.12
However, if a number has zeros as the first two decimal digits, R suppresses zeros on the display:
> a = 14.0034 > round(a, digits=2) > a > 14
How can we do R to show the first decimal digits, even if they are zeros? I especially need this in the plots. I searched here and some people suggested using options(digits=2)
, but that makes R have weird behavior.
source share