date-and-date-time-shifting | R Documentation |
date_shift()
shifts x
to the target
weekday. You can shift to the next
or previous weekday. If x
is currently on the target
weekday, you can
choose to leave it alone or advance it to the next instance of the target
.
There are separate help pages for shifting dates and date-times:
dates (Date)
date-times (POSIXct/POSIXlt)
date_shift(x, target, ..., which = "next", boundary = "keep")
x |
A date or date-time vector. |
target |
A weekday created from Generally this is length 1, but can also be the same length as |
... |
These dots are for future extensions and must be empty. |
which |
One of:
|
boundary |
One of:
|
x
shifted to the target
weekday.
# See the type specific documentation for more examples
x <- as.Date("2019-01-01") + 0:1
# A Tuesday and Wednesday
as_weekday(x)
monday <- weekday(clock_weekdays$monday)
# Shift to the next Monday
date_shift(x, monday)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.