round2: A function to round 0.5 down

Description Usage Arguments Value References Examples

View source: R/round2.R

Description

This function rounds values based on mathematical rules. That is, numbers ending below 0.5 round down and numbers ending with 0.5 and greater round up.

Usage

1
round2(x, n)

Arguments

x

a numeric vector

n

number of decimal places

Value

The value returned is a numeric vector, x, rounded to n decimals places.

References

https://stackoverflow.com/questions/12688717/round-up-from-5

Examples

1
2
round2(143.05, 1)
round2(143.048, 2)

Example output

[1] 143.1
[1] 143.05

edbuildr documentation built on June 2, 2021, 5:07 p.m.