round_time: A generic function for rounding date and time values

Description Usage Arguments Value Examples

View source: R/ts_plot.R

Description

A generic function for rounding date and time values

Usage

1
round_time(x, n, tz)

Arguments

x

A vector of class POSIX or Date.

n

Unit to round to. Defaults to mins. Numeric values treated as seconds. Otherwise this should be one of "mins", "hours", "days", "weeks", "months", "years" (plural optional).

tz

Time zone to be used, defaults to "UTC" (Twitter default)

Value

If POSIXct then POSIX. If date then Date.

Examples

1
2
3
4
5
## class posixct
round_time(Sys.time(), "12 hours")

## class date
unique(round_time(seq(Sys.Date(), Sys.Date() + 100, "1 day"), "weeks"))

mkearney/rtweet documentation built on Sept. 29, 2021, 12:01 p.m.