time_gcd_diff {timeplyr} | R Documentation |
Fast greatest common divisor of time differences
Description
Fast greatest common divisor of time differences
Usage
time_gcd_diff(
x,
time_by = NULL,
time_type = getOption("timeplyr.time_type", "auto"),
tol = sqrt(.Machine$double.eps)
)
Arguments
x |
Time variable. |
time_by |
Time unit.
|
time_type |
If "auto", |
tol |
Numeric tolerance for gcd algorithm. |
Value
A list of length 1.
Examples
library(timeplyr)
library(lubridate)
library(cppdoubles)
time_gcd_diff(1:10)
time_gcd_diff(seq(0, 1, 0.2))
time_gcd_diff(time_seq(today(), today() + 100, time_by = "3 days"))
time_gcd_diff(time_seq(now(), len = 10^2, time_by = "125 seconds"))
# Monthly gcd using lubridate periods
quarter_seq <- time_seq(today(), len = 24, time_by = months(4))
time_gcd_diff(quarter_seq, time_by = months(1), time_type = "period")
time_gcd_diff(quarter_seq, time_by = "months", time_type = "duration")
# Detects monthly granularity
double_equal(time_gcd_diff(as.vector(time(AirPassengers))), 1/12)