linear_time() creates a linear time representation using specified granules and a chronon. Granules are larger time units that define the structure of time (e.g., years, months), while the chronon is the smallest indivisible time unit (e.g., days, hours).

linear_time(chronon, granules = list())

Arguments

chronon

A time unit object representing the chronon (e.g., tu_day(1))

granules

A list of time unit objects representing the granules (e.g., list(tu_year(1), tu_month(1)))

Value

An function used to create continuous time points.

Examples


# A year-month time representation with months as the chronon
ym <- linear_time(tu_month(1L), list(tu_year(1L)))
#> Error in linear_time(tu_month(1L), list(tu_year(1L))): could not find function "linear_time"
ym(Sys.Date())
#> Error in ym(Sys.Date()): could not find function "ym"

# A year-quarter-month time representation with months as the chronon
yqm <- linear_time(tu_month(1L), list(tu_year(1L), tu_quarter(1L)))
#> Error in linear_time(tu_month(1L), list(tu_year(1L), tu_quarter(1L))): could not find function "linear_time"
yqm(1:100)
#> Error in yqm(1:100): could not find function "yqm"
yqm(Sys.Date())
#> Error in yqm(Sys.Date()): could not find function "yqm"

# A year-day time representation with days as the chronon
yd <- linear_time(tu_day(1L), list(tu_year(1L)))
#> Error in linear_time(tu_day(1L), list(tu_year(1L))): could not find function "linear_time"
yd(Sys.Date())
#> Error in yd(Sys.Date()): could not find function "yd"

ymd_h <- linear_time(tu_hour(1L), list(tu_year(1L), tu_month(1L), tu_day(1L)))
#> Error in linear_time(tu_hour(1L), list(tu_year(1L), tu_month(1L), tu_day(1L))): could not find function "linear_time"
ymd_h(Sys.time())
#> Error in ymd_h(Sys.time()): could not find function "ymd_h"