Could you tell me why the dates are coming off weird? I will insert an executable code below. You may notice that date1 and date2 have the wrong dates.

The link to download the database df: df.xlsx - Google Sheets

```
df<-read_excel('C:/Users/Desktop/df.xlsx')
df<-subset(df,df$date2<df$date1)
dim_data<-dim(df)
day<-c(seq.Date(from = as.Date(df$date2[1]),
to = as.Date(df$date2[dim_data[1]]),
by = "1 day"))
df_grouped<-matrix(nrow = 9,ncol=6)
colnames(df_grouped)<-c("Id","date1","date2","Week","D","DR01")
for (k in 1:9) {
df_grouped[k,]<-c(subset(df,date2==day[k])$Id[1],
subset(df,date2==day[k])$date1[1],
subset(df,date2==day[k])$date2[1],
subset(df,date2==day[k])$Week[1],
subset(df,date2==day[k])$D[1],
sum(subset(df,date2==day[k])$DR01))
}
> df_grouped
Id date1 date2 Week D DR01
[1,] "1" "1626739200" "1617321600" "Friday" NA "21"
[2,] "1" "1626739200" "1617408000" "Saturday" NA "24"
[3,] NA NA NA NA NA "0"
[4,] NA NA NA NA NA "0"
[5,] NA NA NA NA NA "0"
[6,] NA NA NA NA NA "0"
[7,] "1" "1626739200" "1617840000" "Thursday" "Hol" "21"
[8,] "1" "1626739200" "1617926400" "Friday" NA "11"
[9,] "1" "1626739200" "1618012800" "Saturday" NA "14
```