Rounding of Numbers, and convert to string

str_num(x, digits = 2)

Arguments

x

a numeric vector. Or, for round and signif, a complex vector.

digits

integer indicating the number of decimal places (round) or significant digits (signif) to be used. For round, negative values are allowed (see ‘Details’).

Examples

format(round(2, 2)) # 2
#> [1] "2"
str_num(2, 2) # 2.00
#> [1] "2.00"