robust_round {DIZtools}R Documentation

Round numbers without problems.

Description

Round numbers without problems.

Usage

robust_round(
  x,
  digits = 2,
  thousands_separator = "",
  decimal_separator = ".",
  lower_indicator = TRUE
)

Arguments

x

(numeric) The numeric input vector to round.

digits

(int, optional) The number of digits after the decimal separator to round to.

thousands_separator

(string, optional) Used as mark between every 3 decimals before the decimal point.

decimal_separator

(string, optional) The character to be used to indicate the numeric decimal point.

lower_indicator

(Boolaen, optional, default = TRUE) If the result is (since it is rounded) zero: Should there be displayed a lower-indicator? E.g. DIZtools::robust_round(0.00001) results internally in "0.00". The more intuitive result therefore would be "<0.01", which can be enabled using the parameter 'lower_indicator == TRUE'.

Value

Rounded numbers as string.

Examples

{
  robust_round(c(1.234567, 987123.987654321))
  #> [1] "1.23"   "987.99"
}

[Package DIZtools version 1.0.1 Index]