hi,

to turn year and week into the date one can do the following:

as.Date('2018 05 Sun', "%Y %W %a")

however, when we want the Sunday (1st day of week) of the 1st week of 2018
we get NA because 1/1/2018 was on Monday

as.Date('2018 00 Mon',format="%Y %U %a")
## 2018-01-01
as.Date('2018 00 Sun',format="%Y %U %a")
## NA

btw the same goes for last week
as.Date('2017 53 Sun',format="%Y %U %a")
## 2017-12-31
as.Date('2017 53 Mon',format="%Y %U %a")
## NA

So my question is :
how do i get
from "2018 00 Sun" to 2018-12-31
and
from "2017 53 Mon" to 2018-01-01

i realize i can loop over days of week and do some if/then statements,
but is there a built in function?

thank you
peter





-- 
Peter Salzman, PhD
Department of Biostatistics and Computational Biology
University of Rochester

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to