This is a custom round function that rounds a number to the nearest whole number down if the decimal is below 0.5 and up if it is above. Default R round behavior rounds decimals of 0.5 down when the whole number is even and this function avoids that behavior.

round(x, n)

Arguments

x

the number or vector of numbers to round (numeric)

n

the number of decimal places to round (integer)

Value

returns a rounded version of the value provided

Examples

round(4.5, 0)
#> [1] 5