fmt_fix_digits: Format a number with a fixed number of digits

View source: R/formatters.R

fmt_fix_digitsR Documentation

Format a number with a fixed number of digits

Description

Format a number with a fixed number of digits

Usage

fmt_fix_digits(xs, digits = 2)

Arguments

xs

a vector of numbers or a character vector representing numbers

digits

number of digits of precision

Examples

# what we want to avoid
as.character(round(c(.4001, .1000, .5500), 2))

fmt_fix_digits(c(.4001, .1000, .5500), 1)
fmt_fix_digits(c(.4001, .1000, .5500), 2)
fmt_fix_digits(c(.4001, .1000, .5500), 3)

tjmahr/printy documentation built on March 4, 2024, 1:25 a.m.