Learn R Programming

pkr (version 0.1.3)

Round: Round Half Away from Zero

Description

This is an ordinary rounding function, so called round half away from zero

Usage

Round(x, n = 0)

Arguments

x

numeric to be rounded

n

indicating decimal digits

Value

ordinarily rounded value

Details

The function round in R base rounds to the even number, i.e. round(0.5) is 0 not 1. If you want rounding 0.5 be 1, you can use this Round function. This function is for the consistency with other software like MS-Excel, SAS.

References

See wikipedia subject "Rounding"

Examples

Run this code
# NOT RUN {
(x = 1:10 - 0.5)
Round(x)
round(x) # compare with the above
# }

Run the code above in your browser using DataLab