I am trying to calculate cumulative time between experiment initiation and each temperature measurement I made during an experiment. My experiment has 50+ samples (i.e. A1,A2,B1,B2 ect) and each sample was initiated at a different time/day.
I want to treat time as a continuous variable so I need to calculate the total (cumulative time in hours) for each temp measurement, as indicated by a total time variable (below).
Is there a way to do this without telling R the start and end time for each sample? How can I get cumulative time for each temperature measurement?
An example of how the data looks is shown below:
Date Time Sample Temp **Total Time**
2017-06-28 13:58 A1 13.67870139 0
2017-06-29 16:08 A1 13.34256319 (time between 06-28 13:58 and 06-29 16:08)
2017-06-30 07:32 A1 12.84005139 (time between 06-28 13:58 and 06-30 07:32)
2017-06-30 19:14 A1 12.84005139 ect
2017-07-01 07:40 A1 11.83983472
2017-07-01 19:20 A1 11.83983472
2017-07-02 07:53 A1 11.75332292
2017-07-02 19:06 A1 11.75332292
2017-07-03 07:45 A1 11.74469167
2017-07-03 19:04 A1 11.74469167
2017-07-04 08:15 A1 11.45409583
Thanks!
PS- I haven't tried anything because I can only find example where there is a "start time" and "end time" col. I guess I could create a start time col for each sample and ask r to calculate the time diff between start time and the time of each measurement.... I don't know how to make R make a start time col for the earliest measurement for each sample. I could spend a whole day doing it in excel but there must bet a better solution!