[R] get start and end date of ISO weeks giving a date as input
luisfo89 at yahoo.es
Thu Sep 8 13:20:14 CEST 2016
Here there's a way of doing what you requested.
# your date '2010-08-21' as Date object
dd <- as.Date(strptime("2010-08-21", format="%Y-%m-%d", tz="GMT"))
# take the first day of the year as Date object, i.e. 2010-01-01 in our
ref.date <- as.Date(strptime(paste0(year(dd),"-01-01"),
# the start and end dates
bound.dates <- ref.date + 7 * (week(dd)-1) + c(0,6)
I hope you find it useful.
/PhD Student | PhD Candidate
IMDEA Networks Institute/
On 09/08/2016 12:13 PM, Veronica Andreo wrote:
> Hello list,
> Is there a quick way to get start and end date (%Y-%m-%d) from ISO
> weeks if I only have dates?
> For example, I have this date in which some event happened:
> "2010-08-21". Not only I want the ISO week, which I can obtain either
> with isoweek (lubridate) or ISOweek (ISOweek), but I want the start
> and end date of that ISO week.
> Do I need to print all ISO weeks from the period of interest and
> sample there for start and end date? Or is there a better way to do
> Thanks a lot in advance!
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help