How to round up to the nearest 10 (or 100 or X)?

The plyr library has a function round_any that is pretty generic to do all kinds of rounding. For example

library(plyr)
round_any(132.1, 10)               # returns 130
round_any(132.1, 10, f = ceiling)  # returns 140
round_any(132.1, 5, f = ceiling)   # returns 135

Leave a Comment