Skip to content

Instantly share code, notes, and snippets.

@danlewer
Created August 20, 2024 12:45
Show Gist options
  • Save danlewer/0356c22b95ba5d435163a340aa1cfa44 to your computer and use it in GitHub Desktop.
Save danlewer/0356c22b95ba5d435163a340aa1cfa44 to your computer and use it in GitHub Desktop.
Round up
roundup <- function (x, dig = 2) {
l <- floor(log10(x)) + 1
r <- ceiling(x / (10 ^ (l-dig)))
r * 10 ^ (l-dig)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment