Rounds values in its first argument to the specified number of decimal places, returning character, ensuring first decimal digits are showed even when they are zeros.

round0(x, digits = 0)

Arguments

x

A numeric vector.

digits

Integer indicating the number of decimal places. Defaults to 0.

Value

A character vector.

References

https://stackoverflow.com/questions/42105336/how-to-round-a-number-and-make-it-show-zeros

See also

Examples

a = 14.0034
round0(a,2)
#> [1] "14.00"

b = 10
round0(b,1)
#> [1] "10.0"