tf_splitcombine: Split / Combine functional fragments

tf_splitR Documentation

Split / Combine functional fragments

Description

tf_split separates each function into a vector of functions defined on a sub-interval of its domain, either with overlap at the cut points or without.

tf_combine joins functional fragments together to create longer (or more densely evaluated) functions.

Usage

tf_split(x, splits, include = c("both", "left", "right"))

tf_combine(..., strict = FALSE)

Arguments

x

a tf object.

splits

numeric vector containing arg-values at which to split.

include

which of the end points defined by splits to include in each of the resulting split functions. Defaults to "both", other options are "left" or "right". See examples.

...

tf-objects of identical lengths to combine

strict

only combine functions whose argument ranges do not overlap, are given in the correct order & contain no duplicate values at identical arguments? defaults to FALSE. If strict == FALSE, only the first function values at duplicate locations are used, the rest are discarded (with a warning).

Value

for tf_split: a list of tf objects.

for tf_combine: a tfd with the combined subfunctions on the union of the input tf_arg-values

Examples

x <- tfd(1:100, arg = 1:100)
tf_split(x, splits = c(20, 80))
tf_split(x, splits = c(20, 80), include = "left")
tf_split(x, splits = c(20, 80), include = "right")
  x <- tf_rgp(5)
  tfs <- tf_split(x, splits = c(.2, .6))
  x2 <- tf_combine(tfs[[1]], tfs[[2]], tfs[[3]])
  # tf_combine(tfs[[1]], tfs[[2]], tfs[[3]], strict = TRUE) # errors out - duplicate values!
  all.equal(x, x2)
  # combine works for different input types:
  tfs2_sparse <- tf_sparsify(tfs[[2]])
  tfs3_spline <- tfb(tfs[[3]])
  tf_combine(tfs[[1]], tfs2_sparse, tfs3_spline)
  # combine(.., strict = F) can be used to coalesce different measurements
  # of the same process over different grids:
  x1 <- tfd(x, arg = tf_arg(x)[seq(1, 51, by = 2)])
  x2 <- tfd(x, arg = tf_arg(x)[seq(2, 50, by = 2)])
  tf_combine(x2, x1, strict = FALSE) == x

  plot(tf_combine(x2, x1, strict = FALSE))
  points(x1, col = "blue", pch = "x")
  points(x2, col = "red", pch = "o")

tf documentation built on April 7, 2026, 5:07 p.m.