roundup: Rounds numbers up

View source: R/other_functions.R

roundupR Documentation

Rounds numbers up

Description

A function that rounds positive numbers up when the last digit is a 5. For negative numbers ending in 5, the function actually rounds down. "Round away from zero" is the most accurate description of this function.

Usage

roundup(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.5)  # -2
round(2.6)   # 3

# Round up
roundup(2.4)  # 2
roundup(2.5)  # 3
roundup(-2.5) # -3
roundup(2.6)  # 3


common documentation built on Sept. 29, 2022, 9:06 a.m.