I have this dataset:
<tbody>
</tbody>The first thing I want to do is add a subindex on User and Date.
<tbody>
</tbody>The second thing I want is a column that takes the difference between times in its row (A) and the row after it (A+1). "n/a" means I don't really care about this value. I just want the interday marginal differences.
<tbody>
</tbody>
User | Date | Time |
A | 9/1/2019 | 8:00 AM |
A | 9/1/2019 | 10:00 AM |
A | 9/1/2019 | 4:00 PM |
A | 9/1/2019 | 5:00 PM |
A | 9/2/2019 | 8:00 AM |
A | 9/2/2019 | 5:00 PM |
B | 9/1/2019 | 9:00 AM |
B | 9/1/2019 | 3:00 PM |
B | 9/1/2019 | 5:00 PM |
<tbody>
</tbody>
User | Date | Time | User/Date Index | |
A | 9/1/2019 | 8:00 AM | 1 | |
A | 9/1/2019 | 10:00 AM | 2 | |
A | 9/1/2019 | 4:00 PM | 3 | |
A | 9/1/2019 | 5:00 PM | 4 | |
A | 9/2/2019 | 8:00 AM | 1 | |
A | 9/2/2019 | 5:00 PM | 2 | |
B | 9/1/2019 | 9:00 AM | 1 | |
B | 9/1/2019 | 3:00 PM | 2 | |
B | 9/1/2019 | 5:00 PM | 3 |
<tbody>
</tbody>
User | Date | Time | User/Date Index | Marginal Difference |
A | 9/1/2019 | 8:00 AM | 1 | 02:00:00 |
A | 9/1/2019 | 10:00 AM | 2 | 06:00:00 |
A | 9/1/2019 | 4:00 PM | 3 | 01:00:00 |
A | 9/1/2019 | 5:00 PM | 4 | n/a |
A | 9/2/2019 | 8:00 AM | 1 | 09:00:00 |
A | 9/2/2019 | 5:00 PM | 2 | n/a |
B | 9/1/2019 | 9:00 AM | 1 | 06:00:00 |
B | 9/1/2019 | 3:00 PM | 2 | 02:00:00 |
B | 9/1/2019 | 5:00 PM | 3 | n/a |
<tbody>
</tbody>