Wim Broens Posted February 28, 2019 Share Posted February 28, 2019 Hi, I am trying to find a solution for following situation. I have 2 tables: A: Is showing a number of tasks that have a start and stop time and a type of task. It can be UP or DOWN B: Is showing another list of task that only have start and stop time. What I want to achieve is adding an extra column in table A that indicates how much time (minutes) overlaps a DOWN task overlaps with a task in table B Following drawing can explain it a little bit more: I am starting to learn Rscripting. If somebody have a solution or can at least push me in the right directory, I am happy guy gr Wim Link to comment Share on other sites More sharing options...
Gaia Paolini Posted March 1, 2019 Share Posted March 1, 2019 Hi I can probably help but it would really help me if you uploaded the two datasets, to save re-typing the data myself. Gaia Link to comment Share on other sites More sharing options...
Wim Broens Posted March 1, 2019 Author Share Posted March 1, 2019 Hi, I used just an excel for the testdata. I attached it Link to comment Share on other sites More sharing options...
Wim Broens Posted March 1, 2019 Author Share Posted March 1, 2019 please find the data in my 2nd post Link to comment Share on other sites More sharing options...
Gaia Paolini Posted March 1, 2019 Share Posted March 1, 2019 Hi this works if the second table does not contain rows that overlap in time. If so, you will have to modify the code slightly, and also best to output a separate table, as the new 'Overlap' column would contain more rows than the original table, if the same task overlaps with more than one loss, and you would want to specify which lossnr it overlaps with. It is based on the logic of a previous community answer: https://community.spotfire.com/questions/creating-daily-timeline-show-numbe... Comments are within the code. Basically the code enumerates both tables into sequences of minutes, then merges them, counts the minutes that appear in both tables, and outputs the result as a new column, Overlap, to the Tasks table. Make sure that the columns sent into the data function for the first table do not contain Overlap, when already defined, otherwise it causes a cyclic dependency. It depends on the library data.table being installed. You can either install it with the TERR Tools interface, or uncomment the piece of code, or if you are using TSSS have it installed on the server. I am uploading the code as well in case you cannot load the dxp. Gaia Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now