Joins an arbitrary of time series lists by name and time. Pairs of zoo objects are joined with zoo::merge.zoo()
. Names that are not shared across all input TSLs are ignored, and observations with no matching time are filled with NA and then managed via tsl_handle_NA()
depending on the value of the argument na_action
.
Arguments
- ...
(required, time series lists) names of the time series lists to merge.
- na_action
(required, character) NA handling action. Available options are:
"impute" (default): NA cases are interpolated from neighbors as a function of time (see
zoo::na.approx()
andzoo::na.spline()
)."omit": rows with NA cases are removed.
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_names_clean()
,
tsl_names_get()
,
tsl_names_set()
,
tsl_names_test()
,
tsl_ncol()
,
tsl_nrow()
,
tsl_repair()
,
tsl_subset()
,
tsl_time()
,
tsl_time_class_set()
,
tsl_to_df()
Examples
#generate two time series list to join
tsl_a <- tsl_simulate(
n = 2,
cols = 2,
irregular = TRUE,
seed = 1
)
#needs renaming
tsl_b <- tsl_simulate(
n = 3,
cols = 2,
irregular = TRUE,
seed = 2
) |>
tsl_colnames_set(
names = c("c", "d")
)
#join
tsl <- tsl_join(
tsl_a,
tsl_b
)
#> distantia::tsl_join(): 676 NA cases generated were handled via distantia::tsl_handle_NA() with 'na_action = 'impute''.
#plot result
if(interactive()){
tsl_plot(
tsl = tsl
)
}