round_small | R Documentation |
Rounding of a number smaller than specified precision doesn't coerce to 0.
round_small(x, method = c("round", "signif"), digits = 3, sci = FALSE)
x |
a numeric vector or matrix |
method |
use either |
digits |
integer indicating number of decimal places to round to |
sci |
if |
This function is useful when we have small p-values and don't want to show the scientific notation, or coercion to 0. Instead we show an upper bound. For example, if a p-value is 2e-05 and we want to round to 3 digits, the function will return "< 0.001".
If precision of number is larger than desired rounding, the default
round
is used. Otherwise, we provide an upper bound instead of
coercion to 0.
Derek Chiu
# Vector inputs
round_small(2e-04)
round_small(5e-04)
round_small(6e-04)
# Matrix input
set.seed(12)
x <- matrix(rexp(25, 3), nrow = 5)
round_small(x, digits = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.