Disclaimer: I am not a user of this package.

1) This is a plain text mailing list... your email was mangled in transit. Send in plain text format to the R mailing lists to avoid confusing potential respondents.

2) It is bad form to post here and not point out that you have already asked elsewhere [1]. It looks like you already received a quality answer there. Failing to link to previous threads is almost as impolite as cross-posting to multiple mailing lists... read the Posting Guide for more on mailing list etiquette.

3) Note that there is a mailing list intended for questions about this package: the datatable-help mailing list.

[1] 
https://stackoverflow.com/questions/48141991/foverlaps-and-within-in-data-table

On Sun, 7 Jan 2018, Rahul Sharm wrote:

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]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnew...@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to