Description Usage Arguments Details Examples
sch_jump()
shifts a sequence of dates by "jumping" from x
to
x + jump
. After the jump, sch_adjust()
is called with the adjustment
to ensure that if the new dates are events, they are adjusted to the next
available non-event date.
sch_step()
steps over a sequence of dates 1 day at a time, for n
days.
After each step, sch_adjust()
is called with an adjustment of days(1)
.
This has different results from sch_jump()
with a jump of days(n)
, and
is more appropriate for shifting by "n business days".
1 2 3 |
x |
A vector of dates. |
jump |
A lubridate period object, such as |
schedule |
A schedule or event. |
adjustment |
An adjustment to make whenever a date falls on an event. If this is a lubridate period object, such as If this is a function or formula (i.e., a lambda function), then it
should accept 2 arguments, the dates to adjust and the original |
n |
The number of days to step. Can be negative to step backwards. |
For shifting by "n business days", sch_step()
is often more appropriate.
Imagine you are on a Friday and want to shift forward 2 days using a
schedule that marks weekends as events. There are two options:
sch_jump()
- Jump forward 2 days to Sunday, and apply the adjustment
.
Assuming adjustment = days(1)
was used, that means the result is Monday.
sch_step()
- Step forward 1 day to Saturday, apply an adjustment of
days(1)
, which rolls forward to Monday. Step forward 1 day to Tuesday,
and no further adjustment is required.
The second option more naturally lends itself to business logic. Two business days from Friday is Tuesday.
1 2 3 4 5 6 7 8 | # 2019-09-13 is a Friday
# Note that here we "jump" to Sunday, then adjust, leaving us on Monday
sch_jump("2019-09-13", days(2), on_weekends())
# Here we step 1 day to Saturday, adjust to Monday,
# then step 1 day to Tuesday
sch_step("2019-09-13", 2, on_weekends())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.