roundPOSIXt: Round POSIXt Objects to Specified Interval

View source: R/functions.R

roundPOSIXtR Documentation

Round POSIXt Objects to Specified Interval

Description

Round POSIXt objects to specified intervals such as ‘5 minutes’.

Usage

roundPOSIXt(t, interval, up = FALSE)

Arguments

t

a vector that inherits from class POSIXt

interval

A character string of the form “num units”, in which num is a number, and units is sec, min, hour or day. num and units must be separated by white space.

up

logical: round down (the default) or up?

Details

roundPOSIXt rounds an input of class POSIXt; it returns a vector of class POSIXct.

Value

POSIXct

Author(s)

Enrico Schumann

References

B.D. Ripley and K. Hornik. Date-Time Classes. R-News, 1(2):8–12, 2001.

See Also

DateTimeClasses

Examples

times <- as.POSIXct("2012-03-24 22:17:27") + 1:3
roundPOSIXt(times, "10 min")
roundPOSIXt(times, "10 min", TRUE)

enricoschumann/datetimeutils documentation built on April 2, 2024, 11:10 a.m.