seq.clock_year_month_weekday {clock}R Documentation

Sequences: year-month-weekday

Description

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

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

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

Usage

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

Arguments

from

⁠[clock_year_month_weekday(1)]⁠

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

from is always included in the result.

to

⁠[clock_year_month_weekday(1) / NULL]⁠

A "year" or "month" precision year-month-weekday 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.

by

⁠[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.

length.out

⁠[positive integer(1) / NULL]⁠

The length of the resulting sequence.

If specified, along.with must be NULL.

along.with

⁠[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.

Value

A sequence with the type of from.

Examples

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

# Which we can then set the indexed weekday of
set_day(x, clock_weekdays$sunday, index = "last")

[Package clock version 0.7.0 Index]