round0 | R Documentation |
Round numbers and add leading + trailing zeros
round0(
x,
digits = 0,
pre = 2,
width = digits + pre + ifelse(digits == 0, 0, 1),
flag = 0,
...
)
x |
Value(s) |
digits |
Number of digits (after decimal separator) to keep. DEFAULT: 0 |
pre |
Minimum number of characters before the decimal separator. DEFAULT: 2 |
width |
Total width (number of characters including dot). DEFAULT: digits+pre (+1 if needed) |
flag |
Flag. Could be "" for spaces. DEFAULT: "0" |
... |
Further arguments passed to |
Character string vector
Berry Boessenkool, berry-b@gmx.de, Jun 2017
formatC
, sprintf
round0( pi*10^(-3:5), 2)
stopifnot(round0(17.3, 2) == "17.30")
round0(7.3)
round0(c(7.3,777.1234), 2)
round0(c(0.2,7.3,12.8), 2, pre=1)
round0(c(0.2,7.3,12.8), 1, pre=3, flag="") # spaces instead of zeros
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.