roundHalfUpTextFormat | R Documentation |
This function rounds numbers with a 'round-up' strategy for rounding off a 5. The function rounds for a specified number of digits and format number to a: 'xxx.xxx' text.
roundHalfUpTextFormat(x, digits = 0)
x |
Numeric vector to round. |
digits |
Integer with number of digits to consider, 0 by default. |
The following workflow is used:
numbers are rounded with the roundHalfUp
function, see the ? roundHalfUp
for more details
on the rounding strategy
round numbers are formatted to character in the format: 'xxx.xxx' with pads leading zeros
A character vector with the rounded number. NA values are returned as 'NA' as string.
Laure Cougnaud and Michela Pasetto
roundHalfUp for the rounding customization.
# number of digits higher than number of decimal
roundHalfUpTextFormat(x = c(0.345, 0.567, -0.98), digits = 2)
# number of digits lower than number of decimal
roundHalfUpTextFormat(x = c(0.345, 0.567, -0.98), digits = 0)
# by default, 'digits' is 0!
roundHalfUpTextFormat(x = c(0.345, 0.567, -0.98))
# padding zeros
roundHalfUpTextFormat(1.23, 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.