Learn R Programming

distantia (version 2.0.0)

tsl_join: Join Time Series Lists

Description

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

Value

time series list

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.

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_to_df()

Examples

Run this code

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

#plot result
if(interactive()){
  tsl_plot(
    tsl = tsl
  )
}

Run the code above in your browser using DataLab