round_any: Round to multiple of any number.

View source: R/round_any.R

round_anyR Documentation

Round to multiple of any number.

Description

Round to multiple of any number.

Usage

round_any(x, accuracy, f = round)

Arguments

x

numeric, date-time (POSIXct), or hms vector to round.

accuracy

number to round to; for POSIXct or hms objects, a number of seconds.

f

rounding function: floor, ceiling or round

Examples


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)

# For POSIXct data-types
round_any(Sys.time() + 1:10, 5)
round_any(Sys.time() + 1:10, 5, floor)
round_any(Sys.time(), 3600)

# For hms data-types
round_any(hms::as_hms(603), 60)


skgrange/threadr documentation built on May 11, 2024, 12:16 p.m.