Formats numbers with a prespecified number of digits after the decimal point.

num_digits(x, digits, format = "f", ...)

Arguments

x

a numeric vector

digits

an integer to indicate the number of digits to show.

format

format type passed to formatC().

...

additional parameters passed to formattable().

See also

Other numeric vectors: num_accounting(), num_comma(), num_currency(), num_percent(), num_scientific()

Examples

num_digits(pi, 2)
#> [1] 3.14
num_digits(123.45678, 3)
#> [1] 123.457