Lets have a sequence of dates,
df = data.frame(date = seq(as.Date('2022-01-01'),as.Date('2022-01-31'),by = 1))
I want to start the week from Tuesday and then cut the dates to create new column week giving the week number. Required output is,
date week
1 2022-01-01 1
2 2022-01-02 1
3 2022-01-03 1
4 2022-01-04 2
5 2022-01-05 2
Similarly, if I wanted to start the week from Wednesday the expected output is,
date week
1 2022-01-01 1
2 2022-01-02 1
3 2022-01-03 1
4 2022-01-04 1
5 2022-01-05 2
6 2022-01-06 2
How can I get this done?
If the week were to start from Monday I would have used,
df%>% mutate(week = cut.Date(df$date, breaks = "1 week", labels = FALSE))
date week
1 2022-01-01 1
2 2022-01-02 1
3 2022-01-03 2
4 2022-01-04 2
5 2022-01-05 2
Thank you for any help...