I'm looking to find faster and more accurate methods to find the difference between two times, preferably using the xts or zoo packages. At the moment I would like to find the number of milliseconds difference between two times, and to do this I have been using the difftimes function (with units set to seconds and I then multiply this number by 1000 to get milliseconds - for example: as.numeric(difftime(time2, time1, units = "secs")) * 1000).
This seems to work reasonably well, but I'm hoping for something faster and more accurate so I wish to use xts or zoo instead. However, I'm not sure how to go about finding the difference between two times using these packages.
Are they any particular functions in xts or zoo which can find the difference between two times? In addition, are they any functions which can allow me to compute the millisecond difference between two times?
EDIT: There's something important I forgot to include in my original topic: the reason why I want more accurate time methods is due to a rounding issue in my times. I am having a similar issue as given in this topic here: How R formats POSIXct with fractional seconds where my times are off by a fraction of a second (e.g. I get the time 11:12:53.332 rather than the time 11:12:53.333). Up until now I have 'fixed' this issue by including adding a smaller fraction of time to the number i.e. I can change 11:12:53.332 to 11:12:53.333 by writing 11:12:53.332 + 1e-6. However, I now need to go down to microseconds, so rather than 'fix' this issue by adding another fraction I would much rather use a package or function or something to achieve this task.