stats.apply.rounding | R Documentation |
Not all statistics should be rounded in the same way, or at all. This
function will apply rounding selectively to a list of statistics as returned
by stats.default
. In particular we don't round counts (N, NMISS and
FREQ), and for MIN, MAX and MEDIAN the digits
is interpreted as the
minimum number of significant digits, so that we don't loose any
precision. Percentages are rounded to a fixed number of decimal places
(default 1) rather than a specific number of significant digits.
stats.apply.rounding( x, digits = 3, digits.pct = 1, round.median.min.max = TRUE, round.integers = TRUE, round5up = TRUE, rounding.fn = signif_pad, ... )
x |
A list, such as that returned by |
digits |
An integer specifying the number of significant digits to keep. |
digits.pct |
An integer specifying the number of digits after the decimal place for percentages. |
round.median.min.max |
Should rounding applied to median, min and max? |
round.integers |
Should rounding be limited to digits to the right of the decimal point? |
round5up |
Should numbers with 5 as the last digit always be rounded
up? The standard R approach is "go to the even digit" (IEC 60559 standard,
see |
rounding.fn |
The function to use to do the rounding. Defaults to
|
... |
Further arguments. |
A list with the same number of elements as x
. The rounded
values will be character
(not numeric
) and will have 0 padding
to ensure consistent number of significant digits.
signif_pad
stats.default
x <- round(exp(rnorm(100, 1, 1)), 6) stats.default(x) stats.apply.rounding(stats.default(x), digits=3) stats.apply.rounding(stats.default(round(x, 1)), digits=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.