Created
February 20, 2015 00:18
-
-
Save mattparker-wf/5a194786b53831586f66 to your computer and use it in GitHub Desktop.
Get the Monday or Sunday preceding a given date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: the masterful Marc Schwartz, in this R-help thread: | |
# http://r.789695.n4.nabble.com/previous-monday-date-td3786395.html | |
# Getting the Monday preceding any date | |
# See ?cut.Date for additional info | |
as.Date(cut(Sys.Date(), breaks = "weeks")) | |
# Alternatively, the preceding Sunday: | |
as.Date(cut(Sys.Date(), breaks = "weeks", start.on.monday = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment