Round to multiple of any number.
round_any(x, accuracy, f = round)
x | numeric or date-time (POSIXct) vector to round |
---|---|
accuracy | number to round to; for POSIXct objects, a number of seconds |
f |
round_any(135, 10)#> [1] 140round_any(135, 100)#> [1] 100round_any(135, 25)#> [1] 125round_any(135, 10, floor)#> [1] 130round_any(135, 100, floor)#> [1] 100round_any(135, 25, floor)#> [1] 125round_any(135, 10, ceiling)#> [1] 140round_any(135, 100, ceiling)#> [1] 200round_any(135, 25, ceiling)#> [1] 150#> [1] "2019-12-31 11:47:00 UTC" "2019-12-31 11:47:00 UTC" #> [3] "2019-12-31 11:47:05 UTC" "2019-12-31 11:47:05 UTC" #> [5] "2019-12-31 11:47:05 UTC" "2019-12-31 11:47:05 UTC" #> [7] "2019-12-31 11:47:05 UTC" "2019-12-31 11:47:10 UTC" #> [9] "2019-12-31 11:47:10 UTC" "2019-12-31 11:47:10 UTC"#> [1] "2019-12-31 11:47:00 UTC" "2019-12-31 11:47:00 UTC" #> [3] "2019-12-31 11:47:00 UTC" "2019-12-31 11:47:00 UTC" #> [5] "2019-12-31 11:47:00 UTC" "2019-12-31 11:47:05 UTC" #> [7] "2019-12-31 11:47:05 UTC" "2019-12-31 11:47:05 UTC" #> [9] "2019-12-31 11:47:05 UTC" "2019-12-31 11:47:05 UTC"#> [1] "2019-12-31 12:00:00 UTC"