Converts numeric values to character strings with fixed decimal formatting using sprintf().

my_round(x, digit = 0)

Arguments

x

A numeric vector to format.

digit

Number of decimal places to display, 0 by default.

Value

A character vector of formatted values.

Examples

my_round(3.1415, 2)
#> [1] "3.14"
my_round(3, 2)
#> [1] "3.00"