roundHalfUpTextFormat {clinUtils} | R Documentation |
Round a number with 'round-up' strategy for rounding off a 5 in text format
Description
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.
Usage
roundHalfUpTextFormat(x, digits = 0)
Arguments
x |
Numeric vector to round. |
digits |
Integer with number of digits to consider, 0 by default. |
Details
The following workflow is used:
numbers are rounded with the
roundHalfUp
function, see the? roundHalfUp
for more details on the rounding strategyround numbers are formatted to character in the format: 'xxx.xxx' with pads leading zeros
Value
A character vector with the rounded number. NA values are returned as 'NA' as string.
Author(s)
Laure Cougnaud and Michela Pasetto
See Also
roundHalfUp for the rounding customization.
Examples
# 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)
[Package clinUtils version 0.2.0 Index]