> log_df[1:10, ]
tagid happened status
1 03B2ACE7 2016-06-28 18:07:36 open
2 03B2ACE7 2016-06-28 18:36:15 closed
3 03B2ACE7 2016-06-29 07:29:59 open
4 03B2ACE7 2016-06-29 08:06:23 closed
5 03B2ACE7 2016-06-30 16:10:48 open
6 03B2ACE7 2016-06-30 17:23:55 open
7 03B2ACE7 2016-07-01 10:12:06 closed
8 03B2ACE7 2016-07-01 13:39:58 closed
9 03B2ACE7 2016-07-02 10:08:40 open
10 03B2ACE7 2016-07-02 13:33:01 closed
...
Above is my data. What I'd like to produce is:
tagid open closed
1 03B2ACE7 2016-06-28 18:07:36 2016-06-28 18:36:15
2 03B2ACE7 2016-06-29 07:29:59 2016-06-29 08:06:23
3 03B2ACE7 2016-06-30 16:10:48 2016-07-01 10:12:06
...
I was trying to make it work with dcast in reshape2 package. However, I have to be selective where I only pick up
"open" that is very first one and only those that comes right after closed and "close" that comes right before open.
So from log_df, row 6 and 7 will be ignored..
I am really stuck and not sure how I can go about this.. Maybe dcast is not the best approach?
Please help! Thank you so much!