Skip to content

Instantly share code, notes, and snippets.

@sotoattanito
Last active Nov 5, 2021
Embed
What would you like to do?
Round half up in R.
round.off <- function (x, digits=0)
{
posneg = sign(x)
z = trunc(abs(x) * 10 ^ (digits + 1)) / 10
z = floor(z * posneg + 0.5) / 10 ^ digits
return(z)
}
@sotoattanito
Copy link
Author

sotoattanito commented Mar 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment