how can I have a data set of only time intervals (no dates) in R, like the following:
TREATMENT_A TREATMENT_B
1:01:12 0:05:00
0:34:56 1:08:09
and compute mean times, etc, and draw boxplots with time intervals in the y-axis?
I am new to R, and I searched for this but found no example in the net.
Thanks
The chron-package has a ‘times’ class that supports arithmetic. You could also do all of that with POSIXct objects and format the date-time output to not include the date. I thought
axis.POSIXctfunction has aformatargument that should let you have time outputs. However, it does not seem to get dispatched properly, so I needed to construct the axis “by hand.”There did turn out to be an appropriate method,
Axis.POSIXt(to which I thoughtboxplotshould have been turning for plotting, but it did not seem to recognize the class of the ‘y’ argument):Regarding your request for something “simpler”, take a look at theis ggplot2 based solution, using the dft dataframe defined above with POSIXct times. (I did try with the chron-times object but got a message saying ggplot did not support that class):