round_any

0th

Percentile

Round to multiple of any number.

Round to multiple of any number.

Keywords
manip
Usage
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
Aliases
  • round_any
Examples
library(plyr) 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)
Documentation reproduced from package plyr, version 1.8.4, License: MIT + file LICENSE

Community examples

flebber.crue@gmail.com at Aug 1, 2017 plyr v1.8.4

## Rounding decimals To round up to the nearest 0.5 use ceiling. ``` > round_any(2.2, 0.5, ceiling) [1] 2.5 ``` To round down use floor ``` > round_any(2.2, 0.5, floor) [1] 2 ```