Learn R Programming

edbuildr (version 0.3.0)

round2: A function to round 0.5 down

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

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

Run this code
# NOT RUN {
round2(143.05, 1)
round2(143.048, 2)
# }

Run the code above in your browser using DataLab