Closed Moohan closed 3 years ago
Simple function for rounding to a nearest number, example usage could be to round all output figures to the nearest 5 for suppression.
round_nearest_n <- function(x, n) { rounded <- round(x / n) * n) return(rounded) }
A function for this already exists within the tidyverse suite: https://www.rdocumentation.org/packages/plyr/versions/1.8.6/topics/round_any
Simple function for rounding to a nearest number, example usage could be to round all output figures to the nearest 5 for suppression.