Created
August 20, 2024 12:45
-
-
Save danlewer/0356c22b95ba5d435163a340aa1cfa44 to your computer and use it in GitHub Desktop.
Round up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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