Function that pads numeric values to be the same length by adding spaces to the left-hand side and trailing zeros after the decimal place.

format_numbers(x)

Arguments

x

A numeric vector.

Value

A character vector.

Examples

# Decimal values
message( paste0( format_numbers( round( rnorm( 3 ), 2 ) ), "\n" ) )
#> -1.54
#> -0.79
#> -1.98
# Whole numbers
message( paste0( format_numbers( rbinom( 3, 100, .1 ) ), "\n" ) )
#>  6
#> 11
#> 10