Hi,
I have sequential days:
seq_days=seq(from=as.Date('2019-12-28'), to=as.Date('2020-12-25'), by = "1 day")
I want to repeat each consecutive 7 days 6 times.
For example:
2019-12-28
2019-12-29
2019-12-30
2019-12-31
2020-01-01
2020-01-02
2020-01-03
2019-12-28
2019-12-29
2019-12-30
2019-12-31
2020-01-01
2020-01-02
2020-01-03
2019-12-28
2019-12-29
2019-12-30
2019-12-31
2020-01-01
2020-01-02
2020-01-03
...
rep function does not work because I don't want to rep each row. I just want to rep all 7 consecutive dates.
seq_days=as.data.frame(seq_days) %>%
slice(rep(1:n(), each = 6))
Thank you!
SOLUTION:
a=-6
b=0
repted_days=NULL
for (i in 1:52){
a=a+7
b=b+7
rep=rep(seq_days[a:b,],6)
repted_days=rbind(repted_days,data.frame(rep))
}