date_spanning_seq: Spanning sequence: date and date-time

View source: R/date.R

date_spanning_seqR Documentation

Spanning sequence: date and date-time

Description

date_spanning_seq() generates a regular sequence along the span of x, i.e. along ⁠[min(x), max(x)]⁠. For dates, this generates a day precision sequence, and for date-times it generates a second precision sequence.

Usage

date_spanning_seq(x)

Arguments

x

⁠[Date / POSIXct / POSIXlt]⁠

A date or date-time vector.

Details

Missing and infinite values are automatically removed before the sequence is generated.

For date-times, sys-time based sequences are generated, consistent with date_seq() when using a second precision by value.

If you need more precise sequence generation, call range() and date_seq() directly.

Value

A sequence along ⁠[min(x), max(x)]⁠.

Examples

x <- date_build(2020, c(1, 2, 1), c(10, 5, 12))
date_spanning_seq(x)

# Missing and infinite dates are removed before the sequence is generated
x <- c(x, NA, Inf, -Inf)
x

date_spanning_seq(x)

# For date-times, sequences are generated at second precision
x <- date_time_build(
  2020, 1, 2, 3, c(5, 4, 5), c(10, 48, 12),
  zone = "America/New_York"
)
x

date_spanning_seq(x)

clock documentation built on Sept. 11, 2024, 8:39 p.m.