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.
the numbers to be rounded. Can also be a vector or numeric array.
the desired number of decimal digits
logical, should the p-value-style "less-than blurb" convention be used? Default
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
TRUE, then values below the rounding thresholds will be represented using the "less than" convention. For example, with
plurb=TRUE, the number 0.0004 will be represented as
Assaf P. Oron
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.