Round to multiple of any number.
Examples
round_any(135, 10)
#> [1] 140
round_any(135, 100)
#> [1] 100
round_any(135, 25)
#> [1] 125
round_any(135, 10, floor)
#> [1] 130
round_any(135, 100, floor)
#> [1] 100
round_any(135, 25, floor)
#> [1] 125
round_any(135, 10, ceiling)
#> [1] 140
round_any(135, 100, ceiling)
#> [1] 200
round_any(135, 25, ceiling)
#> [1] 150
round_any(Sys.time() + 1:10, 5)
#> [1] "2026-02-04 01:45:20 UTC" "2026-02-04 01:45:20 UTC"
#> [3] "2026-02-04 01:45:25 UTC" "2026-02-04 01:45:25 UTC"
#> [5] "2026-02-04 01:45:25 UTC" "2026-02-04 01:45:25 UTC"
#> [7] "2026-02-04 01:45:25 UTC" "2026-02-04 01:45:30 UTC"
#> [9] "2026-02-04 01:45:30 UTC" "2026-02-04 01:45:30 UTC"
round_any(Sys.time() + 1:10, 5, floor)
#> [1] "2026-02-04 01:45:20 UTC" "2026-02-04 01:45:20 UTC"
#> [3] "2026-02-04 01:45:20 UTC" "2026-02-04 01:45:20 UTC"
#> [5] "2026-02-04 01:45:25 UTC" "2026-02-04 01:45:25 UTC"
#> [7] "2026-02-04 01:45:25 UTC" "2026-02-04 01:45:25 UTC"
#> [9] "2026-02-04 01:45:25 UTC" "2026-02-04 01:45:30 UTC"
round_any(Sys.time(), 3600)
#> [1] "2026-02-04 02:00:00 UTC"