A function to round numbers up where the last digit is 5 or above. The function contains a parameter to control the number decimals to round to.

round_up(x, digits = 0)

Arguments

x

A vector of values to round.

digits

A number of decimal places to round to. Default is zero.

Value

The rounded data vector.

Examples

# Round to even
round(2.4)  # 2
round(2.5)  # 2
round(2.6)  # 3

# Round up
round_up(2.4) # 2
round_up(2.5) # 3
round_up(2.6) # 3