seq.clock_duration | R Documentation |
This is a duration method for the seq()
generic.
Using seq()
on duration objects always retains the type of from
.
When calling seq()
, exactly two of the following must be specified:
to
by
Either length.out
or along.with
## S3 method for class 'clock_duration'
seq(from, to = NULL, by = NULL, length.out = NULL, along.with = NULL, ...)
from |
A duration to start the sequence from. |
to |
A duration to stop the sequence at.
|
by |
The unit to increment the sequence by. If If |
length.out |
The length of the resulting sequence. If specified, |
along.with |
A vector who's length determines the length of the resulting sequence. Equivalent to If specified, |
... |
These dots are for future extensions and must be empty. |
If from > to
and by > 0
, then the result will be length 0. This matches
the behavior of rlang::seq2()
, and results in nicer theoretical
properties when compared with throwing an error. Similarly, if from < to
and by < 0
, then the result will also be length 0.
A sequence with the type of from
.
seq(duration_days(0), duration_days(100), by = 5)
# Using a duration `by`. Note that `by` is cast to the type of `from`.
seq(duration_days(0), duration_days(100), by = duration_weeks(1))
# `to` is cast from 5 years to 60 months
# `by` is cast from 1 quarter to 4 months
seq(duration_months(0), duration_years(5), by = duration_quarters(1))
seq(duration_days(20), by = 2, length.out = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.