Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sotoattanito
Last active November 5, 2021 22:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sotoattanito/8e6fad4b7322ceae9f14f342985f1681 to your computer and use it in GitHub Desktop.
Save sotoattanito/8e6fad4b7322ceae9f14f342985f1681 to your computer and use it in GitHub Desktop.
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

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