Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

align.time

Align seconds, minutes, and hours to beginning of next period.


Description

Change timestamps to the start of the next period, specified in multiples of seconds.

Usage

align.time(x, ...)

## S3 method for class 'xts'
align.time(x, n=60, ...)

shift.time(x, n=60, ...)

adj.time(x, ...)

Arguments

x

object to align

n

number of seconds to adjust by

...

additional arguments. See details.

Details

This function is an S3 generic. The result is to round up to the next period determined by n modulo x.

Value

A new object of class(x)

Author(s)

Jeffrey A. Ryan with input from Brian Peterson

See Also

Examples

x <- Sys.time() + 1:1000

# every 10 seconds
align.time(x, 10)

# align to next whole minute
align.time(x, 60)

# align to next whole 10 min interval
align.time(x, 10 * 60)

xts

eXtensible Time Series

v0.12.1
GPL (>= 2)
Authors
Jeffrey A. Ryan [aut, cph], Joshua M. Ulrich [cre, aut], Ross Bennett [ctb], Corwin Joy [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.