Description Usage Arguments Details Author(s) See Also
Rounds numbers to always have the specified number of decimal digits, rather than R's "greedy" most-compact rounding convention. Includes optional "<0.0..." override adequate for representing small p-values.
1 |
numbers |
the numbers to be rounded. Can also be a vector or numeric array. |
digits |
the desired number of decimal digits |
plurb |
logical, should the p-value-style "less-than blurb" convention be used? Default |
R's standard round utility rounds to at most the number of digits specified. When the number happens to round more "compactly", it rounds to fewer digits. Thus, for example, round(4.03,digits=2) yields 4 as an answer. This is undesirable when trying to format a table, e.g., for publication.
niceRound solves this problem by wrapping a format call around the round call. The result will always have digits decimal digits. In addition, since reporting p-values always involves rounding, if the argument plurb is TRUE, then values below the rounding thresholds will be represented using the "less than" convention. For example, with digits=3 and plurb=TRUE, the number 0.0004 will be represented as <0.001.
Assaf P. Oron <assaf.oron.at.seattlechildrens.org>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.