Learn R Programming

clock (version 0.7.1)

date_spanning_seq: 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)

Value

A sequence along [min(x), max(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.

Examples

Run this code
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)

Run the code above in your browser using DataLab