I have a data similar to the one below
sdt1 = DataFrame(ID = 1:2, StartTime = DateTime(["4/13/2016 07:00",
"4/13/2016 07:15"], "m/d/y H:M"), EndTime = DateTime(["4/13/2016 12:00",
"4/13/2016 12:15"], "m/d/y H:M"))
I would like to get the sequence between StartTime and EndTime by 30 minutes
I can get it formatted using
for i in 1:nrow(sdt1)
si =
Dates.format([sdt1[i,:StartTime]:Dates.Minute(30):sdt1[i,:EndTime]],
"HH:MM")
println(si)
end
and get the result as
Any["07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30","12:00"]
Any["07:15","07:45","08:15","08:45","09:15","09:45","10:15","10:45","11:15","11:45","12:15"]
Is it possible to get an output like the one I get with `data.table` from R
by storing the intermediate results in a array or so?
library(data.table)
dt1 <- data.table(ID = 1:2, StartTime =as.POSIXct(c("4/13/2016 07:00",
"4/13/2016 07:15"), "%m/%d/%Y %H:%M", tz = "GMT"), EndTime
=as.POSIXct(c("4/13/2016 12:00", "4/13/2016 12:15"), "%m/%d/%Y %H:%M", tz =
"GMT"))
dt1[, .(time = format(seq(StartTime, EndTime, by = "30 min"),
"%H:%M")) ,by = ID]
ID time
1: 1 07:00
2: 1 07:30
3: 1 08:00
4: 1 08:30
5: 1 09:00
6: 1 09:30
7: 1 10:00
8: 1 10:30
9: 1 11:00
10: 1 11:30
11: 1 12:00
12: 2 07:15
13: 2 07:45
14: 2 08:15
15: 2 08:45
16: 2 09:15
17: 2 09:45
18: 2 10:15
19: 2 10:45
20: 2 11:15
21: 2 11:45
22: 2 12:15
ID time
Thanking you,