Skip to contents

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.

Usage

tsl_join(..., na_action = "impute")

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() and zoo::na.spline()).

  • "omit": rows with NA cases are removed.

Value

time series list

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
  )
}