Find the first day and last days of the first week of the year: for more information, see %W , %W , %V in the ?strptime section. Keep in mind that the strptime conventions strptime very subtle (for example, you need exactly the right number of digits), possibly depending on the operating system and, possibly, depending on the language ...
firstday <- as.Date(strptime("2010-01-0",format="%Y-%W-%w"))
Now set the dates starting from those days:
seq.Date(firstday,as.Date("2010-12-31"),by="1 week") seq.Date(lastday,as.Date("2010-12-31"),by="1 week")
You can use for example. paste0(year,"-01-0") , if you want to do it more generally (without hard coding in a year).
source share