Round any number to a specified number of places, with 5's being rounded up. This is as an alternative to round in base R, which sometimes rounds 5's down due to an international standard. For more information see the round() documentation: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Round.html

roundFiveUp(value, dp)

Arguments

value

number to be rounded

dp

number of decimal places to round to

Value

Rounded number

Details

You can use a negative value for the decimal places. For example: -1 would round to the nearest 10 -2 would round to the nearest 100 and so on.

Examples

roundFiveUp(2495, -1)
#> [1] 2500
roundFiveUp(2495.85, 1)
#> [1] 2495.9