View source: R/print_decimals_specified.R
force_decimals | R Documentation |
Force printing a specified number of decimals for a number
force_decimals(x, decimals = 2, round_zero = TRUE)
x |
the numeric values to be printed |
decimals |
how many decimals are to be printed. Defaults to 2. |
round_zero |
whether small values should be rounded to zero or whether
they should be displayed as e.g. < .01. See details.
Defaults to |
By default, force_decimals()
will round numbers that are small enough
down to zero, e.g., 0.0004 will be rounded to 0.00. If
round_zero = FALSE
, force_decimals(0.0004)
will return
"< 0.01"
instead. See examples.
Character vector of length length(x)
. The number(s) in the required format.
Martin Papenberg martin.papenberg@hhu.de
force_decimals(c(1.23456, 0.873, 2.3456))
force_decimals(c(1.23456, 0.873, 2.3456), 3)
force_decimals(c(0.004, 0.001, 0.0005, 0.02))
force_decimals(c(0.004, 0.001, 0.0005, 0.02), round_zero = FALSE)
force_decimals(c(0.004, 0.001, 0.0005, 0.02), 3, round_zero = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.