padding | R Documentation |
A family of functions for formatting numbers and then padding with spaces so that table columns can be both centered and decimal aligned.
pad_counts(x, digits = 0L)
pad_prop(x, digits, fmt_small = TRUE, keep_zero = FALSE, output = NULL)
pad_corr(x, digits, output = NULL)
pad_decimal(
x,
digits,
fmt_small = FALSE,
max_value = NULL,
keep_zero = FALSE,
output = NULL
)
x |
Number or number string to be formatted |
digits |
Number of decimal places to retain |
fmt_small |
Indicator for replacing zero with |
keep_zero |
If |
output |
The output type for the rendered document. One of |
max_value |
If |
pad_counts
should be used to pad integer numbers. This wraps
base::format()
to add a comma separator.
pad_prop
should be used to pad decimal numbers between [0,1]. This wraps
fmt_prop()
to round to a specified number of digits
and optionally
remove the leading zero.
pad_corr
should be used to pad decimal numbers between [-1,1]. This wraps
fmt_corr()
, and is similar to pad_prop
, but accounts for negative numbers
when adding padding.
pad_decimal
should be used to pad decimal number that are not bounded. This
wraps fmt_digits()
to round to a specified number of decimal places.
A character vector of the same length as x
.
Other formatters:
fmt_table()
,
formatting
pad_counts(sample(1:1000, size = 20))
pad_prop(c(0.001, runif(5)), digits = 2)
pad_corr(runif(10, -1, 1), digits = 2)
pad_decimal(runif(10, 1, 100), digits = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.