Description Usage Arguments Details Value Source See Also Examples
The function precision_prefix_
provides a suggested precision for
use with SI prefix to use,
given a value
to format, and the difference between the values,
step
, that will be formatted.
precision_prefix
calculates the suggested SI Prefix given a
numeric vector of values to format, x
.
1 2 3 | precision_prefix(x, prefix = NULL)
precision_prefix_(step, prefix)
|
x |
A numeric vector of values to be formatted. |
prefix |
The SI prefix to use. This is any valid argument for
|
step |
Numeric: Minimum absolute difference between values that will be formatted. |
The suggested precision, p, when formatting a vector with an SI Prefix of 10^k is,
p = max(0, floor(log10(d))),
where d is the maximum absolute value between elements in the vector.
Named list of two elements:
Integer vector: The suggested precision
An named integer vector of SI prefixes. The names are the
SI prefix names, and the values are the exponents, as in
SI_PREFIXES
.
The d3-format
function precisionPrefix.
precision_fixed
for the suggested precision to
use with formats that use a fixed number of digits after the decimal point,
and precision_round
for the suggested precision to use with
formats that round to significant digits.
1 2 3 4 | x <- c(1.1e6, 1.2e6, 1.3e6)
p <- precision_prefix(x, 6L)
p$precision
fmt(x, paste0(".", p$precision), si_prefix = 6L)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.