Round value based on magnitude

roundx_n(x)

Arguments

x

A numeric value to be rounded. Values >= 100 are rounded to 1 decimal place. Values < 100 and >=1 are rounded to two decimal places. Values <1 are rounded to three decimal places.

Value

A numeric value rounded based on the magnitude of x

Examples

library(curios)
# Note: R will display right padded zero's below. This is a display manifestation only.
roundx_n(c(0.1234, 1.1234, 100.123))
#> [1]   0.123   1.120 100.100
# Verify rounding does not add right hand padding
roundx_n(c(0.1234, 1.1234, 100.123))[3]
#> [1] 100.1