The function is designed to work even when the epoch length is less
than one second (e.g., for raw accelerometry data). Thus, it is not
possible to base the code on convenient difftime
methods. Instead,
numeric operations are performed after running unclass
on the input.
This sometimes results in miniscule fluctuations of the calculated epoch
length (e.g., +/- 0.0000002). Thus, the code rounds everything to the
precision indicated by digits
. For most applications, the default
value (digits = 6
) should be well past the range of meaningful
fluctuations and lead to a favorable outcome. But the ditits
argument can also be adjusted if greater assurance is needed.
After rounding, the code checks for the existence of multiple epoch
lengths. If they are detected (e.g., due to a discontinuity in the file), a
warning is issued and the most prevalent epoch length is returned. The
warning will specify all the different epoch lengths that were detected,
which may be useful information for troubleshooting.