View source: R/dates_and_times.R
epoch_length_sec | R Documentation |
Determine epoch length in seconds
epoch_length_sec(timestamps, digits = 6)
timestamps |
POSIX-formatted input |
digits |
for rounding. See details |
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.
The epoch length of the data, in seconds
epoch_length_sec(Sys.time() + 0:5) epoch_length_sec(Sys.time() + seq(0, 25, 5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.