The functions tsl_time()
and tsl_time_summary()
summarize the time features of a time series list.
tsl_time()
returns a data frame with one row per time series in the argument 'tsl'tsl_time_summary()
returns a list with the features captured bytsl_time()
, but aggregated across time series.
Both functions return keywords useful for the functions tsl_aggregate()
and tsl_resample()
, depending on the value of the argument keywords
.
Arguments
- tsl
(required, list) Time series list. Default: NULL
- keywords
(optional, character string or vector) Defines what keywords are returned. If "aggregate", returns valid keywords for
zoo_aggregate()
. If "resample", returns valid keywords forzoo_resample()
. If both, returns all valid keywords. Default: c("aggregate", "resample").
Value
tsl_time()
: data frame with the following columns:name
(string): time series name.rows
(integer): number of observations.class
(string): time class, one of "Date", "POSIXct", or "numeric."units
(string): units of the time series.length
(numeric): total length of the time series expressed inunits
.resolution
(numeric): average interval between observations expressed inunits
.begin
(date or numeric): begin time of the time series.end
(date or numeric): end time of the time series.keywords
(character vector): valid keywords fortsl_aggregate()
ortsl_resample()
, depending on the value of the argumentkeywords
.
tsl_time_summary()
: list with the following objects:class
(string): time class, one of "Date", "POSIXct", or "numeric."units
(string): units of the time series.begin
(date or numeric): begin time of the time series.end
(date or numeric): end time of the time series.resolution_max
(numeric): longer time interval between consecutive samples expressed inunits
.resolution_min
(numeric): shorter time interval between consecutive samples expressed inunits
.keywords
(character vector): valid keywords fortsl_aggregate()
ortsl_resample()
, depending on the value of the argumentkeywords
.units_df
(data frame) data frame for internal use withintsl_aggregate()
andtsl_resample()
.
See also
Other tsl_management:
tsl_burst()
,
tsl_colnames_clean()
,
tsl_colnames_get()
,
tsl_colnames_prefix()
,
tsl_colnames_set()
,
tsl_colnames_suffix()
,
tsl_count_NA()
,
tsl_diagnose()
,
tsl_handle_NA()
,
tsl_join()
,
tsl_names_clean()
,
tsl_names_get()
,
tsl_names_set()
,
tsl_names_test()
,
tsl_ncol()
,
tsl_nrow()
,
tsl_repair()
,
tsl_subset()
,
tsl_time_class_set()
,
tsl_to_df()
Examples
#simulate a time series list
tsl <- tsl_simulate(
n = 3,
rows = 150,
time_range = c(
Sys.Date() - 365,
Sys.Date()
),
irregular = TRUE
)
#time data frame
tsl_time(
tsl = tsl
)
#> name rows class units length resolution begin end keywords
#> 1 A 134 Date days 363.6355 2.734102 2023-12-22 2024-12-20 years, q....
#> 2 B 148 Date days 360.6768 2.453584 2023-12-25 2024-12-19 quarters....
#> 3 C 117 Date days 362.6552 3.126338 2023-12-22 2024-12-18 years, q....
#time summary
tsl_time_summary(
tsl = tsl
)
#> $class
#> [1] "Date"
#>
#> $units
#> [1] "days"
#>
#> $begin
#> [1] "2023-12-22"
#>
#> $end
#> [1] "2024-12-20"
#>
#> $resolution_max
#> [1] 0.6175973
#>
#> $resolution_min
#> [1] 14.85011
#>
#> $keywords
#> [1] "years" "quarters" "months" "weeks" "days"
#>
#> $units_df
#> factor base_units units threshold keyword
#> 4 NA days years 365 TRUE
#> 5 NA days quarters 90 TRUE
#> 6 NA days months 30 TRUE
#> 7 NA days weeks 7 TRUE
#> 8 NA days days 1 TRUE
#>