Generates a function that rounds numeric values to a specified number of digits and returns them as character strings.
Arguments
- digits
Integer indicating the number of decimal places. Defaults to 0
.
Value
A function that takes a numeric value and returns a character string of the rounded value.
Examples
# Create a formatter with default settings
formatter <- fmt_round()
formatter(3.14159) # "3"
#> [1] "3"
# Create a formatter with 2 decimal places
formatter2 <- fmt_round(digits = 2)
formatter2(2.71828) # "2.72"
#> [1] "2.72"