seq.clock_year_month_day {clock}R Documentation

Sequences: year-month-day


This is a year-month-day method for the seq() generic.

Sequences can only be generated for "year" and "month" precision year-month-day vectors.

When calling seq(), exactly two of the following must be specified:


## S3 method for class 'clock_year_month_day'
seq(from, to = NULL, by = NULL, length.out = NULL, along.with = NULL, ...)




A "year" or "month" precision year-month-day to start the sequence from.

from is always included in the result.


⁠[clock_year_month_day(1) / NULL]⁠

A "year" or "month" precision year-month-day to stop the sequence at.

to is cast to the type of from.

to is only included in the result if the resulting sequence divides the distance between from and to exactly.


⁠[integer(1) / clock_duration(1) / NULL]⁠

The unit to increment the sequence by.

If by is an integer, it is transformed into a duration with the precision of from.

If by is a duration, it is cast to the type of from.


⁠[positive integer(1) / NULL]⁠

The length of the resulting sequence.

If specified, along.with must be NULL.


⁠[vector / NULL]⁠

A vector who's length determines the length of the resulting sequence.

Equivalent to length.out = vec_size(along.with).

If specified, length.out must be NULL.


These dots are for future extensions and must be empty.


A sequence with the type of from.


# Monthly sequence
x <- seq(year_month_day(2019, 1), year_month_day(2020, 12), by = 1)

# Which we can then set the day of to get a sequence of end-of-month values
set_day(x, "last")

# Daily sequences are not allowed. Use a naive-time for this instead.
try(seq(year_month_day(2019, 1, 1), by = 2, length.out = 2))
seq(as_naive_time(year_month_day(2019, 1, 1)), by = 2, length.out = 2)

[Package clock version 0.6.1 Index]