Learn R Programming

tidyfst (version 1.8.1)

round0: Round a number and make it show zeros

Description

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.

Usage

round0(x, digits = 0)

Value

A character vector.

Arguments

x

A numeric vector.

digits

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

References

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

See Also

Examples

Run this code
a = 14.0034
round0(a,2)

b = 10
round0(b,1)

Run the code above in your browser using DataLab