[R] foverlaps data.table error
Rahul Sharm
rahulsharm9 at gmail.com
Mon Jan 8 00:01:16 CET 2018
Hello All
Have 2 tables
dt1:
start end kwh10min
2013-04-01 00:00:54 UTC 2013-04-01 01:00:10 UTC 0.05
2013-04-01 00:40:26 UTC 2013-04-01 00:50:00 UTC 0.1
2013-04-01 02:13:20 UTC 2013-04-01 04:53:42 UTC 0.15
2013-04-02 02:22:00 UTC 2013-04-01 04:33:12 UTC 0.2
2013-04-01 02:26:23 UTC 2013-04-01 04:05:12 UTC 0.25
2013-04-01 02:42:47 UTC 2013-04-01 04:34:33 UTC 0.3
2013-04-01 02:53:12 UTC 2013-04-03 05:27:05 UTC 0.35
2013-04-02 02:54:08 UTC 2013-04-02 05:31:15 UTC 0.4
2013-04-03 02:57:16 UTC 2013-04-03 05:29:32 UTC 0.45
dt2: start and end are 10 minute interval blocks spanning 2013-4-1 00:00:00
to 2013-04-04
I want to add the column 3 of dt1 to map as long as the start and end time
are within the 10 minute blocks and keep appending the columns
ideally the output should be
4/1/2013 0:00
4/1/2013 0:10
0.05 0
4/1/2013 0:10
4/1/2013 0:20
0.05 0
4/1/2013 0:20
4/1/2013 0:30
0.05 0
4/1/2013 0:30
4/1/2013 0:40
0.05 0
4/1/2013 0:40
4/1/2013 0:50
0.05 0.01
4/1/2013 0:50
4/1/2013 1:00
0.05 0.01
I tried
setkey(dums,start,end)
setkey(map,start,end)
foverlaps(map,dums,type="within",nomatch=0L)
I keep getting the error
Error in foverlaps(map, dums, type = "within", nomatch = 0L) :
All entries in column start should be <= corresponding entries in column
end in data.table 'y'
[[alternative HTML version deleted]]
More information about the R-help
mailing list