round_any: Round to multiple of any number.

Description Usage Arguments Examples

View source: R/round-any.r

Description

Round to multiple of any number.

Usage

1
round_any(x, accuracy, f = round)

Arguments

x

numeric or date-time (POSIXct) vector to round

accuracy

number to round to; for POSIXct objects, a number of seconds

f

rounding function: floor, ceiling or round

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
round_any(135, 10)
round_any(135, 100)
round_any(135, 25)
round_any(135, 10, floor)
round_any(135, 100, floor)
round_any(135, 25, floor)
round_any(135, 10, ceiling)
round_any(135, 100, ceiling)
round_any(135, 25, ceiling)

round_any(Sys.time() + 1:10, 5)
round_any(Sys.time() + 1:10, 5, floor)
round_any(Sys.time(), 3600)

Example output

[1] 140
[1] 100
[1] 125
[1] 130
[1] 100
[1] 125
[1] 140
[1] 200
[1] 150
 [1] "2017-07-03 05:56:25 UTC" "2017-07-03 05:56:25 UTC"
 [3] "2017-07-03 05:56:30 UTC" "2017-07-03 05:56:30 UTC"
 [5] "2017-07-03 05:56:30 UTC" "2017-07-03 05:56:30 UTC"
 [7] "2017-07-03 05:56:30 UTC" "2017-07-03 05:56:35 UTC"
 [9] "2017-07-03 05:56:35 UTC" "2017-07-03 05:56:35 UTC"
 [1] "2017-07-03 05:56:25 UTC" "2017-07-03 05:56:25 UTC"
 [3] "2017-07-03 05:56:25 UTC" "2017-07-03 05:56:25 UTC"
 [5] "2017-07-03 05:56:25 UTC" "2017-07-03 05:56:30 UTC"
 [7] "2017-07-03 05:56:30 UTC" "2017-07-03 05:56:30 UTC"
 [9] "2017-07-03 05:56:30 UTC" "2017-07-03 05:56:30 UTC"
[1] "2017-07-03 06:00:00 UTC"

plyr documentation built on March 3, 2020, 5:07 p.m.